Forum Discussion

JPL_76's avatar
JPL_76
Copper Contributor
Sep 25, 2023
Solved

VBA to ask for a file location to be manually selected

I have a worksheet that is set out as a report - users pick a customer from a drop down list and the rest of the report is populated based on cell contents on many other worksheets. I am trying to e...
  • SnowMan55's avatar
    Sep 25, 2023

    JPL_76 

    The Application.GetSaveAsFilename method is intended to return a value, but your syntax cannot receive a value. It makes me wonder what you are expecting the method to do.


    Use syntax that captures a value, such as:

        Dim vntFileSpec As Variant
        '
        vntFileSpec = Application.GetSaveAsFilename(InitialFileName:=Range("b2") _
                & " Report" & "_" & Format(Now(), "yyyymmdd_hhmmss") & ".pdf")
        If vntFileSpec = False Then
            '...the user decided not to save.  Exit the procedure or do
            '    whatever else is appropriate.
        Else
            'Use vntFileSpec in your <workbook>.SaveAs or <worksheet>.SaveAs method
            'or <range>.ExportAsFixedFormat method or whatever.
        End If

     

     

Resources