adding a sub folder using activeworkbook.path syntax











up vote
0
down vote

favorite












ok so this is a short peace in a big workbook... All i am trying to do is tell it a certain place to save.



ActiveWorkbook.SaveCopyAs _
FileName:=ActiveWorkbook.Path "OLD " & Range("D1").Value & ".XLSM"


This does exactly as it is supposed to however, i want to say basically
"activeworkbook.path" plus give it one further step and designate a folder called "old" that it will go to.



in essence it would look like this



documentstestmy-file.xlsm


to this



documentstestOLDmy-file.xlsm


any hints?










share|improve this question




























    up vote
    0
    down vote

    favorite












    ok so this is a short peace in a big workbook... All i am trying to do is tell it a certain place to save.



    ActiveWorkbook.SaveCopyAs _
    FileName:=ActiveWorkbook.Path "OLD " & Range("D1").Value & ".XLSM"


    This does exactly as it is supposed to however, i want to say basically
    "activeworkbook.path" plus give it one further step and designate a folder called "old" that it will go to.



    in essence it would look like this



    documentstestmy-file.xlsm


    to this



    documentstestOLDmy-file.xlsm


    any hints?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      ok so this is a short peace in a big workbook... All i am trying to do is tell it a certain place to save.



      ActiveWorkbook.SaveCopyAs _
      FileName:=ActiveWorkbook.Path "OLD " & Range("D1").Value & ".XLSM"


      This does exactly as it is supposed to however, i want to say basically
      "activeworkbook.path" plus give it one further step and designate a folder called "old" that it will go to.



      in essence it would look like this



      documentstestmy-file.xlsm


      to this



      documentstestOLDmy-file.xlsm


      any hints?










      share|improve this question















      ok so this is a short peace in a big workbook... All i am trying to do is tell it a certain place to save.



      ActiveWorkbook.SaveCopyAs _
      FileName:=ActiveWorkbook.Path "OLD " & Range("D1").Value & ".XLSM"


      This does exactly as it is supposed to however, i want to say basically
      "activeworkbook.path" plus give it one further step and designate a folder called "old" that it will go to.



      in essence it would look like this



      documentstestmy-file.xlsm


      to this



      documentstestOLDmy-file.xlsm


      any hints?







      excel vba save filepath file-location






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 7:21









      Pᴇʜ

      20k42650




      20k42650










      asked Nov 12 at 3:37









      Daniel Roy

      154




      154
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          You have a space in "OLD ", and you are not closing off OLD to be a folder.



          The line should look like



          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & Range("D1").Value & ".XLSM"


          I would also strongly consider qualifying your Range("D1") with your worksheet.



          Dim fileNameRng as range
          Set fileNameRng = thisworkbook.worksheets("Sheet1").Range("D1")

          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & fileNameRng.Value & ".XLSM"





          share|improve this answer























          • One simple little back slash just made me feel like an idiot!!! Out of curiosity what is the point of qualifying the range vs just having it straight in code?
            – Daniel Roy
            Nov 12 at 4:00






          • 2




            It's good practice. One day you may not be on the correct worksheet (or workbook) and the value will pull from somewhere that you didn't intend for it to.
            – K.Dᴀᴠɪs
            Nov 12 at 4:02











          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',
          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%2f53255651%2fadding-a-sub-folder-using-activeworkbook-path-syntax%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








          up vote
          2
          down vote



          accepted










          You have a space in "OLD ", and you are not closing off OLD to be a folder.



          The line should look like



          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & Range("D1").Value & ".XLSM"


          I would also strongly consider qualifying your Range("D1") with your worksheet.



          Dim fileNameRng as range
          Set fileNameRng = thisworkbook.worksheets("Sheet1").Range("D1")

          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & fileNameRng.Value & ".XLSM"





          share|improve this answer























          • One simple little back slash just made me feel like an idiot!!! Out of curiosity what is the point of qualifying the range vs just having it straight in code?
            – Daniel Roy
            Nov 12 at 4:00






          • 2




            It's good practice. One day you may not be on the correct worksheet (or workbook) and the value will pull from somewhere that you didn't intend for it to.
            – K.Dᴀᴠɪs
            Nov 12 at 4:02















          up vote
          2
          down vote



          accepted










          You have a space in "OLD ", and you are not closing off OLD to be a folder.



          The line should look like



          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & Range("D1").Value & ".XLSM"


          I would also strongly consider qualifying your Range("D1") with your worksheet.



          Dim fileNameRng as range
          Set fileNameRng = thisworkbook.worksheets("Sheet1").Range("D1")

          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & fileNameRng.Value & ".XLSM"





          share|improve this answer























          • One simple little back slash just made me feel like an idiot!!! Out of curiosity what is the point of qualifying the range vs just having it straight in code?
            – Daniel Roy
            Nov 12 at 4:00






          • 2




            It's good practice. One day you may not be on the correct worksheet (or workbook) and the value will pull from somewhere that you didn't intend for it to.
            – K.Dᴀᴠɪs
            Nov 12 at 4:02













          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          You have a space in "OLD ", and you are not closing off OLD to be a folder.



          The line should look like



          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & Range("D1").Value & ".XLSM"


          I would also strongly consider qualifying your Range("D1") with your worksheet.



          Dim fileNameRng as range
          Set fileNameRng = thisworkbook.worksheets("Sheet1").Range("D1")

          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & fileNameRng.Value & ".XLSM"





          share|improve this answer














          You have a space in "OLD ", and you are not closing off OLD to be a folder.



          The line should look like



          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & Range("D1").Value & ".XLSM"


          I would also strongly consider qualifying your Range("D1") with your worksheet.



          Dim fileNameRng as range
          Set fileNameRng = thisworkbook.worksheets("Sheet1").Range("D1")

          ActiveWorkbook.SaveCopyAs _
          FileName:=ActiveWorkbook.Path & "OLD" & fileNameRng.Value & ".XLSM"






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 12 at 3:51

























          answered Nov 12 at 3:40









          K.Dᴀᴠɪs

          6,667112140




          6,667112140












          • One simple little back slash just made me feel like an idiot!!! Out of curiosity what is the point of qualifying the range vs just having it straight in code?
            – Daniel Roy
            Nov 12 at 4:00






          • 2




            It's good practice. One day you may not be on the correct worksheet (or workbook) and the value will pull from somewhere that you didn't intend for it to.
            – K.Dᴀᴠɪs
            Nov 12 at 4:02


















          • One simple little back slash just made me feel like an idiot!!! Out of curiosity what is the point of qualifying the range vs just having it straight in code?
            – Daniel Roy
            Nov 12 at 4:00






          • 2




            It's good practice. One day you may not be on the correct worksheet (or workbook) and the value will pull from somewhere that you didn't intend for it to.
            – K.Dᴀᴠɪs
            Nov 12 at 4:02
















          One simple little back slash just made me feel like an idiot!!! Out of curiosity what is the point of qualifying the range vs just having it straight in code?
          – Daniel Roy
          Nov 12 at 4:00




          One simple little back slash just made me feel like an idiot!!! Out of curiosity what is the point of qualifying the range vs just having it straight in code?
          – Daniel Roy
          Nov 12 at 4:00




          2




          2




          It's good practice. One day you may not be on the correct worksheet (or workbook) and the value will pull from somewhere that you didn't intend for it to.
          – K.Dᴀᴠɪs
          Nov 12 at 4:02




          It's good practice. One day you may not be on the correct worksheet (or workbook) and the value will pull from somewhere that you didn't intend for it to.
          – K.Dᴀᴠɪs
          Nov 12 at 4:02


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f53255651%2fadding-a-sub-folder-using-activeworkbook-path-syntax%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

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)