+ Reply to Thread
Results 1 to 5 of 5

Help with vba

  1. #1
    Registered User
    Join Date
    07-24-2017
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    3

    Help with vba

    How can I edit this so that it will add a prefix to the save as file name. Ex. The save as box opens and in the file name area it has a designated prefix such as "Q-1". Or, after the user saves the file, the "Q-" is added to the begining of the file name.

    Sub WkbOpn3()
    Dim xFileName As String
    MsgBox "Please save a copy of this workbook." & vbNewLine & "You will be prompted to save when you click OK., vbInformation
    xFileName = Application.GetSaveAsFilename(, "Excel Macro-Enabled Workbook (*.xlsm), *.xlsm", , "Save As xlsm file")
    If xFileName <> "False" Then
    Application.EnableEvents = False
    ActiveWorkbook.SaveAs Filename:=xFileName, FileFormat:=xlOpenXMLWorkbookMacroEnabled
    Application.EnableEvents = True
    Else
    MsgBox "Action Cancelled"
    End If
    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Help with vba

    This will add the prefix in the SaveAs dialog.

    Please Login or Register  to view this content.
    You may want to note in your MsgBox that the file names should start with the prefix.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    07-24-2017
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    3

    Re: Help with vba

    Thank you so much. I thought I tried that, but I guess I missed typed.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Help with vba

    For future reference, please take a moment to read the forum rules and use thread titles that are descriptive of your problem - not what you think the answer might be. (think google search terms?).

    Many members search our previous posts, and thread titles play a big part of the search. I doubt anybody would do a search based on your title?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    07-24-2017
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    3

    Re: Help with vba

    Just out of curiosity. Is there a way to edit the macro to automatically add the Q- without user input. Say, after they put in their file name?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1