I
Ian
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?
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?