D
Dan B
Hi.
I have a series of question / answer sheets as word docs. Each Word doc has
macros to show or hide answers. My intention is perform a batch process to
all docs as follows:
1) Open doc.
2) Print to PDF (answers showing by default) using word doc filename as PDF
filename.
3) Hide the answers using macro built into doc.
4) Print a second PDF using word doc filename (but replace the last
character 'a' with 'q') as PDF filename.
I have a macro that will convert a folder of docs to PDF (filenaming set in
PDF driver). My intention was to customise this to perfrom my complete batch
conversion. The code is as follows:
Sub BatchPrintPDF()
On Error GoTo err_FolderContents
Dim FirstLoop As Boolean
Dim DocList As String
Dim DocDir As String
Dim sPrinter As String
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
..Title = "Select Folder containing the documents to be printed to PDF and
click OK"
..AllowMultiSelect = False
..InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
DocDir = fDialog.SelectedItems.Item(1)
If Right(DocDir, 1) <> "\" Then DocDir = DocDir + "\"
End With
If Documents.Count > 0 Then
Documents.Close Savechanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
FirstLoop = True
DocList = Dir$(DocDir & "*.doc")
Do While DocList <> ""
Documents.Open DocList
With Dialogs(wdDialogFilePrintSetup)
sPrinter = .Printer
..Printer = "Adobe PDF"
..DoNotSetAsSysDefault = True
..Execute
End With
ActiveDocument.PrintOut
ActivePrinter = sPrinter
ActiveDocument.Close Savechanges:=wdDoNotSaveChanges
DocList = Dir$()
FirstLoop = False
Loop
Application.ScreenUpdating = True
ActivePrinter = sPrinter
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
ActivePrinter = sPrinter
End Sub
I guess what I need to know is how to customize this code to do the filename
editing/saving tasks and also how to run the 'hide answers' macro in each
word doc opened.
Big thanks to everyone that's help me get this far. I'm nearly there!
Learning lots,
Dan.
I have a series of question / answer sheets as word docs. Each Word doc has
macros to show or hide answers. My intention is perform a batch process to
all docs as follows:
1) Open doc.
2) Print to PDF (answers showing by default) using word doc filename as PDF
filename.
3) Hide the answers using macro built into doc.
4) Print a second PDF using word doc filename (but replace the last
character 'a' with 'q') as PDF filename.
I have a macro that will convert a folder of docs to PDF (filenaming set in
PDF driver). My intention was to customise this to perfrom my complete batch
conversion. The code is as follows:
Sub BatchPrintPDF()
On Error GoTo err_FolderContents
Dim FirstLoop As Boolean
Dim DocList As String
Dim DocDir As String
Dim sPrinter As String
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
..Title = "Select Folder containing the documents to be printed to PDF and
click OK"
..AllowMultiSelect = False
..InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
DocDir = fDialog.SelectedItems.Item(1)
If Right(DocDir, 1) <> "\" Then DocDir = DocDir + "\"
End With
If Documents.Count > 0 Then
Documents.Close Savechanges:=wdPromptToSaveChanges
End If
Application.ScreenUpdating = False
FirstLoop = True
DocList = Dir$(DocDir & "*.doc")
Do While DocList <> ""
Documents.Open DocList
With Dialogs(wdDialogFilePrintSetup)
sPrinter = .Printer
..Printer = "Adobe PDF"
..DoNotSetAsSysDefault = True
..Execute
End With
ActiveDocument.PrintOut
ActivePrinter = sPrinter
ActiveDocument.Close Savechanges:=wdDoNotSaveChanges
DocList = Dir$()
FirstLoop = False
Loop
Application.ScreenUpdating = True
ActivePrinter = sPrinter
Exit Sub
err_FolderContents:
MsgBox Err.Description
Exit Sub
ActivePrinter = sPrinter
End Sub
I guess what I need to know is how to customize this code to do the filename
editing/saving tasks and also how to run the 'hide answers' macro in each
word doc opened.
Big thanks to everyone that's help me get this far. I'm nearly there!
Learning lots,
Dan.