I have made a VBA macro to save a file as xlsx and pdf, at a set location with a filename taken from a cell in the sheet, after which the save location opens.
Code as follows:
Sub SaveAs()
Dim FName As String
Dim FPath As String
FPath = "PATHNAME HERE"
FName = Sheets("SHEETNAME").Range("E1").Text
ActiveWorkbook.SaveAs Filename:=FPath & "\" & FName, FileFormat:=51
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FPath & "\" & FName, Quality:=xlQualityStandard
Shell "explorer.exe" & " " & "PATHNAME HERE", vbNormalFocus
End Sub
However the folder i am saving those files becomes quite filled, and for easy access i want to open the path in explorer with the just saved pdf selected (as in, I want to open folder with the file selected, not like opening the pdf). Any suggestions how to accomplish this?
FileNPath = FPath & "\" & FName & ".pdf"
Then include that string from your call to explorer. The solution provided below by @katz accomplishes this, when using the full path. – peegeShell "explorer.exe" & " " & FileNPath, vbNormalFocus
) but this actually opens the pdf file. I would like to just have it selected in the opened folder. – user1761646