fantabulator
Member
I use the following code in my introductory worksheet to ask the user for a directory to save reports:
On another worksheet the user can save a PDF report that includes information from the worksheet to form the file and directory name. In the code below which is on my report sheet, currently f27 is where I have stored the path name from the above code(introductory sheet) so I can add it to the directory name. Is there a way to insert the folderpicker data gained from the intro sheet into the code below on my report sheet? My method seems clunky and isn't as reliable on a network as the drives change. I need the folderpicker value and then add j3, j28 and k28 to form the file name but cannot figure out the syntax to make it work.
Thank you,
Code:
Sub filepath()
Dim intChoice As Integer
Dim strPath As String
Application.FileDialog(msoFileDialogFolderPicker).AllowMultiSelect = False
intChoice = Application.FileDialog(msoFileDialogFolderPicker).Show
If intChoice <> 0 Then
strPath = Application.FileDialog( _
msoFileDialogFolderPicker).SelectedItems(1)
Cells(27, 7) = strPath
End If
End Sub
On another worksheet the user can save a PDF report that includes information from the worksheet to form the file and directory name. In the code below which is on my report sheet, currently f27 is where I have stored the path name from the above code(introductory sheet) so I can add it to the directory name. Is there a way to insert the folderpicker data gained from the intro sheet into the code below on my report sheet? My method seems clunky and isn't as reliable on a network as the drives change. I need the folderpicker value and then add j3, j28 and k28 to form the file name but cannot figure out the syntax to make it work.
Code:
fName = .Range("f27").Value & .Range("j3").Value & .Range("j28").Value & .Range("k28").Value
.ExportAsFixedFormat Type:=xlTypePDF, Filename:="s:\" & fName, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Thank you,