|
|
|
date: Fri, 11 Jan 2008 08:11:03 -0800,
group: microsoft.public.publisher.programming
back
Photo Book Ideas?
I use Publisher 2007 to produce photo books. This essentially involves
taking a large number of picture files, putting them all into a book format
using a limited number of pre-defined formats and then producing a pdf file
for uploading. I found that this could be a tedious, time-consuming process
and therefore decided to write some macros to automate the process as much as
possible. What might have taken hours can now be done in a few seconds.
The following code, for example, allows the user to select multiple picture
files (perhaps all those in a particular folder) using a standard Windows
dialog box and to write the results into a text file for subsequent
processing.
Dim myFile As String
Dim Exists As Boolean
Dim Choice As Integer
Dim fs As Object, f As Object
Dim fd As FileDialog
Dim myItem As Variant
myFile = "C:\Users\Ian\Pictures\Create_Book\PictureList.txt"
Exists = IIf(Len(Dir(myFile)) > 0, True, False)
Choice = vbYes
If Exists Then
Choice = MsgBox("A PictureList file already exists. Do you want to
overwrite it?" _
& Chr(13) & Chr(10) & Chr(13) & Chr(10) & _
"(Current selections will otherwise be appended to the existing
file.)", vbYesNo, _
"Overwrite or append?")
If Choice = vbYes Then
Kill myFile
End If
End If
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(myFile, IIf(Choice = vbYes, 2, 8), True)
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.Filters.Clear
fd.Filters.Add "Pictures", "*.jpg", 1
If fd.Show = -1 Then
For Each myItem In fd.SelectedItems
f.WriteLine myItem
Next
End If
f.Close
Set fd = Nothing
MsgBox "Done."
Anybody interested in discussing?
date: Fri, 11 Jan 2008 08:11:03 -0800
author: Ian
RE: Photo Book Ideas?
I've never attempted macros- but I am interested in what you are doing.
In my application, I would be adding just one photo to 300 or so half-page
flyers. Different photos for each flyer. How does your macro know which
photo to place where?
psvogt
"Ian" wrote:
> I use Publisher 2007 to produce photo books. This essentially involves
> taking a large number of picture files, putting them all into a book format
> using a limited number of pre-defined formats and then producing a pdf file
> for uploading. I found that this could be a tedious, time-consuming process
> and therefore decided to write some macros to automate the process as much as
> possible. What might have taken hours can now be done in a few seconds.
>
> The following code, for example, allows the user to select multiple picture
> files (perhaps all those in a particular folder) using a standard Windows
> dialog box and to write the results into a text file for subsequent
> processing.
>
> Dim myFile As String
> Dim Exists As Boolean
> Dim Choice As Integer
> Dim fs As Object, f As Object
> Dim fd As FileDialog
> Dim myItem As Variant
>
> myFile = "C:\Users\Ian\Pictures\Create_Book\PictureList.txt"
> Exists = IIf(Len(Dir(myFile)) > 0, True, False)
> Choice = vbYes
> If Exists Then
> Choice = MsgBox("A PictureList file already exists. Do you want to
> overwrite it?" _
> & Chr(13) & Chr(10) & Chr(13) & Chr(10) & _
> "(Current selections will otherwise be appended to the existing
> file.)", vbYesNo, _
> "Overwrite or append?")
> If Choice = vbYes Then
> Kill myFile
> End If
> End If
> Set fs = CreateObject("Scripting.FileSystemObject")
> Set f = fs.OpenTextFile(myFile, IIf(Choice = vbYes, 2, 8), True)
> Set fd = Application.FileDialog(msoFileDialogFilePicker)
> fd.Filters.Clear
> fd.Filters.Add "Pictures", "*.jpg", 1
> If fd.Show = -1 Then
> For Each myItem In fd.SelectedItems
> f.WriteLine myItem
> Next
> End If
> f.Close
> Set fd = Nothing
> MsgBox "Done."
>
> Anybody interested in discussing?
date: Fri, 18 Jan 2008 13:49:03 -0800
author: psvogt
RE: Photo Book Ideas?
The payoff, if any, would be dependent upon how you might envision being able
to use the text file.
I image that, in your case, you might want to set up a one page publication
with two flyers on it and with placeholders for the pictures. A loop in a
second macro could then replace the top picture, replace the bottom picture,
and then print the page. The loop would repeat these steps 150 times or so
until the macro reached the end of the text file.
If the ordering of the flyers is of importance and if you have to start out
with a set of pictures in no particular order, then I would be inclined to
paste the unsorted text file into a spreadsheet and then, in a separate
column, number them however you might want, sort the list by this number and
paste the file names back into the text file. One way or the other, you
would have to go through some manual process.
"psvogt" wrote:
> Thanks for the tips.
> I'm not sure that would actually save any time, but I'll look into it!
date: Tue, 22 Jan 2008 22:25:01 -0800
author: Ian
|
|