How to use Save As function?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I'm attempting to have my workbook save as a macro-enabled workbook upon execution of my macro. When the macro is initiated, a userform will populate where the user can select a FiscalYear, FormYear, and a FormMonth. The reason for separate years is because FiscalYear will begin in Oct. Oct will be year 18, however it will begin FY19.



I am attempting to insert the value of the FiscalYear into my SaveAs function. The filepath stops after I use FiscalYear and it places the remaining string from the path in front of the DocName I am wanting the workbook to saveas:



Path "J:xyzFY" & FiscalYear & "Templates FY" & FiscalYear
DocName:"G22 Dashboard & " " & FormMonth & " " & "FY" & FiscalYear



The document will save in location "FY & FiscalYear &" as "Templates FY18G22 Dashboard & " " FormMonth & " " & "FY" & FiscalYear



Any advice to show me what I am doing incorrectly in this situation?
Probably a rookie mistake, but any help would be greatly appreciated, thanks!



I have attempted different syntax strategies (use of "" locations, & additions/removals).



Sub Save_Report_As()

'Disabling Display Alerts
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Path = "J:xyzFY" & FiscalYear & "Templates FY" & FiscalYear
DocName = "G22 Dashboard" & " " & FormMonth & " " & "FY" & FiscalYear

ActiveWorkbook.SaveAs filename:=Path & DocName, FileFormat:=52

'Enabling Display Alerts
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub









share|improve this question




















  • 2





    You need to add the file extension as part of Path string.

    – Ryan Wildry
    Jan 3 at 14:29






  • 1





    path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)

    – Cyril
    Jan 3 at 14:31













  • @Cyril Good catch. It would sure be helpful to know what is in the FiscalYear variable.

    – Ryan Wildry
    Jan 3 at 14:37











  • Thanks for the assist! Still newer to VBA and working out these little kinks. That worked like a charm and I appreciate your guys' help. Final question: In the code I have FileFormat:=52 for a macro-enabled workbook. Is a file extension required on the DocName if I have the FileFormat:=52 in the SaveAs line?

    – Derek Harden
    Jan 3 at 14:45











  • you need to match the file format to the extension, e.g., .xlsb = fileformat 50, so yes you need both. see: rondebruin.nl/win/s5/win001.htm

    – Cyril
    Jan 3 at 15:04


















0















I'm attempting to have my workbook save as a macro-enabled workbook upon execution of my macro. When the macro is initiated, a userform will populate where the user can select a FiscalYear, FormYear, and a FormMonth. The reason for separate years is because FiscalYear will begin in Oct. Oct will be year 18, however it will begin FY19.



I am attempting to insert the value of the FiscalYear into my SaveAs function. The filepath stops after I use FiscalYear and it places the remaining string from the path in front of the DocName I am wanting the workbook to saveas:



Path "J:xyzFY" & FiscalYear & "Templates FY" & FiscalYear
DocName:"G22 Dashboard & " " & FormMonth & " " & "FY" & FiscalYear



The document will save in location "FY & FiscalYear &" as "Templates FY18G22 Dashboard & " " FormMonth & " " & "FY" & FiscalYear



Any advice to show me what I am doing incorrectly in this situation?
Probably a rookie mistake, but any help would be greatly appreciated, thanks!



I have attempted different syntax strategies (use of "" locations, & additions/removals).



Sub Save_Report_As()

'Disabling Display Alerts
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Path = "J:xyzFY" & FiscalYear & "Templates FY" & FiscalYear
DocName = "G22 Dashboard" & " " & FormMonth & " " & "FY" & FiscalYear

ActiveWorkbook.SaveAs filename:=Path & DocName, FileFormat:=52

'Enabling Display Alerts
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub









share|improve this question




















  • 2





    You need to add the file extension as part of Path string.

    – Ryan Wildry
    Jan 3 at 14:29






  • 1





    path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)

    – Cyril
    Jan 3 at 14:31













  • @Cyril Good catch. It would sure be helpful to know what is in the FiscalYear variable.

    – Ryan Wildry
    Jan 3 at 14:37











  • Thanks for the assist! Still newer to VBA and working out these little kinks. That worked like a charm and I appreciate your guys' help. Final question: In the code I have FileFormat:=52 for a macro-enabled workbook. Is a file extension required on the DocName if I have the FileFormat:=52 in the SaveAs line?

    – Derek Harden
    Jan 3 at 14:45











  • you need to match the file format to the extension, e.g., .xlsb = fileformat 50, so yes you need both. see: rondebruin.nl/win/s5/win001.htm

    – Cyril
    Jan 3 at 15:04














0












0








0








I'm attempting to have my workbook save as a macro-enabled workbook upon execution of my macro. When the macro is initiated, a userform will populate where the user can select a FiscalYear, FormYear, and a FormMonth. The reason for separate years is because FiscalYear will begin in Oct. Oct will be year 18, however it will begin FY19.



I am attempting to insert the value of the FiscalYear into my SaveAs function. The filepath stops after I use FiscalYear and it places the remaining string from the path in front of the DocName I am wanting the workbook to saveas:



Path "J:xyzFY" & FiscalYear & "Templates FY" & FiscalYear
DocName:"G22 Dashboard & " " & FormMonth & " " & "FY" & FiscalYear



The document will save in location "FY & FiscalYear &" as "Templates FY18G22 Dashboard & " " FormMonth & " " & "FY" & FiscalYear



Any advice to show me what I am doing incorrectly in this situation?
Probably a rookie mistake, but any help would be greatly appreciated, thanks!



I have attempted different syntax strategies (use of "" locations, & additions/removals).



Sub Save_Report_As()

'Disabling Display Alerts
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Path = "J:xyzFY" & FiscalYear & "Templates FY" & FiscalYear
DocName = "G22 Dashboard" & " " & FormMonth & " " & "FY" & FiscalYear

ActiveWorkbook.SaveAs filename:=Path & DocName, FileFormat:=52

'Enabling Display Alerts
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub









share|improve this question
















I'm attempting to have my workbook save as a macro-enabled workbook upon execution of my macro. When the macro is initiated, a userform will populate where the user can select a FiscalYear, FormYear, and a FormMonth. The reason for separate years is because FiscalYear will begin in Oct. Oct will be year 18, however it will begin FY19.



I am attempting to insert the value of the FiscalYear into my SaveAs function. The filepath stops after I use FiscalYear and it places the remaining string from the path in front of the DocName I am wanting the workbook to saveas:



Path "J:xyzFY" & FiscalYear & "Templates FY" & FiscalYear
DocName:"G22 Dashboard & " " & FormMonth & " " & "FY" & FiscalYear



The document will save in location "FY & FiscalYear &" as "Templates FY18G22 Dashboard & " " FormMonth & " " & "FY" & FiscalYear



Any advice to show me what I am doing incorrectly in this situation?
Probably a rookie mistake, but any help would be greatly appreciated, thanks!



I have attempted different syntax strategies (use of "" locations, & additions/removals).



Sub Save_Report_As()

'Disabling Display Alerts
Application.DisplayAlerts = False
Application.ScreenUpdating = False

Path = "J:xyzFY" & FiscalYear & "Templates FY" & FiscalYear
DocName = "G22 Dashboard" & " " & FormMonth & " " & "FY" & FiscalYear

ActiveWorkbook.SaveAs filename:=Path & DocName, FileFormat:=52

'Enabling Display Alerts
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub






excel vba excel-vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 15:54









J.schmidt

661120




661120










asked Jan 3 at 14:26









Derek HardenDerek Harden

215




215








  • 2





    You need to add the file extension as part of Path string.

    – Ryan Wildry
    Jan 3 at 14:29






  • 1





    path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)

    – Cyril
    Jan 3 at 14:31













  • @Cyril Good catch. It would sure be helpful to know what is in the FiscalYear variable.

    – Ryan Wildry
    Jan 3 at 14:37











  • Thanks for the assist! Still newer to VBA and working out these little kinks. That worked like a charm and I appreciate your guys' help. Final question: In the code I have FileFormat:=52 for a macro-enabled workbook. Is a file extension required on the DocName if I have the FileFormat:=52 in the SaveAs line?

    – Derek Harden
    Jan 3 at 14:45











  • you need to match the file format to the extension, e.g., .xlsb = fileformat 50, so yes you need both. see: rondebruin.nl/win/s5/win001.htm

    – Cyril
    Jan 3 at 15:04














  • 2





    You need to add the file extension as part of Path string.

    – Ryan Wildry
    Jan 3 at 14:29






  • 1





    path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)

    – Cyril
    Jan 3 at 14:31













  • @Cyril Good catch. It would sure be helpful to know what is in the FiscalYear variable.

    – Ryan Wildry
    Jan 3 at 14:37











  • Thanks for the assist! Still newer to VBA and working out these little kinks. That worked like a charm and I appreciate your guys' help. Final question: In the code I have FileFormat:=52 for a macro-enabled workbook. Is a file extension required on the DocName if I have the FileFormat:=52 in the SaveAs line?

    – Derek Harden
    Jan 3 at 14:45











  • you need to match the file format to the extension, e.g., .xlsb = fileformat 50, so yes you need both. see: rondebruin.nl/win/s5/win001.htm

    – Cyril
    Jan 3 at 15:04








2




2





You need to add the file extension as part of Path string.

– Ryan Wildry
Jan 3 at 14:29





You need to add the file extension as part of Path string.

– Ryan Wildry
Jan 3 at 14:29




1




1





path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)

– Cyril
Jan 3 at 14:31







path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)

– Cyril
Jan 3 at 14:31















@Cyril Good catch. It would sure be helpful to know what is in the FiscalYear variable.

– Ryan Wildry
Jan 3 at 14:37





@Cyril Good catch. It would sure be helpful to know what is in the FiscalYear variable.

– Ryan Wildry
Jan 3 at 14:37













Thanks for the assist! Still newer to VBA and working out these little kinks. That worked like a charm and I appreciate your guys' help. Final question: In the code I have FileFormat:=52 for a macro-enabled workbook. Is a file extension required on the DocName if I have the FileFormat:=52 in the SaveAs line?

– Derek Harden
Jan 3 at 14:45





Thanks for the assist! Still newer to VBA and working out these little kinks. That worked like a charm and I appreciate your guys' help. Final question: In the code I have FileFormat:=52 for a macro-enabled workbook. Is a file extension required on the DocName if I have the FileFormat:=52 in the SaveAs line?

– Derek Harden
Jan 3 at 14:45













you need to match the file format to the extension, e.g., .xlsb = fileformat 50, so yes you need both. see: rondebruin.nl/win/s5/win001.htm

– Cyril
Jan 3 at 15:04





you need to match the file format to the extension, e.g., .xlsb = fileformat 50, so yes you need both. see: rondebruin.nl/win/s5/win001.htm

– Cyril
Jan 3 at 15:04












1 Answer
1






active

oldest

votes


















0














Will post my comment as an answer so this will stop showing up on the "unanswered" list:



path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54024243%2fhow-to-use-save-as-function%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Will post my comment as an answer so this will stop showing up on the "unanswered" list:



    path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)






    share|improve this answer




























      0














      Will post my comment as an answer so this will stop showing up on the "unanswered" list:



      path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)






      share|improve this answer


























        0












        0








        0







        Will post my comment as an answer so this will stop showing up on the "unanswered" list:



        path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)






        share|improve this answer













        Will post my comment as an answer so this will stop showing up on the "unanswered" list:



        path & "" & docname & ".xlsx" would be more appropriate... you left out the "" between the pathdocname plus the extension (@RyanWildry caught the extension, too)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 3 at 15:33









        CyrilCyril

        3,2001924




        3,2001924
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54024243%2fhow-to-use-save-as-function%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            How to fix TextFormField cause rebuild widget in Flutter

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith