View Single Post
 
Old 05-23-2014, 11:41 AM
mbesspiata mbesspiata is offline Windows 7 64bit Office 2010 64bit
Advanced Beginner
 
Join Date: Mar 2011
Location: Virginia
Posts: 57
mbesspiata is on a distinguished road
Default Open and save Word files

I have a macro to format a text file and I want to save it as a pdf file when formatted. I want a macro to do the opening of the text file and the saving as a pdf file. I recorded these operations but I need to know how to input code so that the file name is not specific. I want it to ask me what file to open and what the file name should be when formatting to pdf. Here is what I recorded.

Macro1 Macro
'
'
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
"C:\Users\mbesspiata\Desktop\Dayton Countsheet File.pdf", ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
ChangeFileOpenDirectory "C:\Users\mbesspiata\Desktop\"
Windows("Document1").Activate
ActiveWindow.Close
End Sub
Sub Macro2()
'
' Macro2 Macro
'
'
ChangeFileOpenDirectory "C:\Users\mbesspiata\Desktop\"
Documents.Open FileName:="Dayton Countsheet File.txt", ConfirmConversions _
:=False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:="", _
Encoding:=1252
End Sub


Mike
Reply With Quote