Thread: [Solved] Insert variable in path name
View Single Post
 
Old 01-03-2019, 03:29 PM
bearcublandon bearcublandon is offline Windows 10 Office 2016
Novice
 
Join Date: Dec 2018
Posts: 24
bearcublandon is on a distinguished road
Default Insert variable in path name

I have the following code that I recorded with the macro recorder.

I would like to save the file in this location but put use the input box to insert the file name. How do I incorporate the input box in the macro. It's been awhile for me doing this so I'm kinda rusty.

Sub Save_To()
'
' Save_To Macro
'
'
Dim Name As String

InputBox "Enter name", "file" = Name

ActiveDocument.ExportAsFixedFormat OutputFileName:= _
"P:\My Documents\Excel\Stock Information\Good Files\PDF\Name.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 _
"P:\My Documents\Excel\Stock Information\Good Files\PDF\"
End Sub

I inserted Name in the path way but I get an error message at this point. The name of the file is showing up as Name but I would like to enter the name in the input box and transfer this into the directory.

Thank you for your help,

Michael
Reply With Quote