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?
excel vba save filepath file-location
add a comment |
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?
excel vba save filepath file-location
add a comment |
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?
excel vba save filepath file-location
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
excel vba save filepath file-location
edited Nov 12 at 7:21
Pᴇʜ
20k42650
20k42650
asked Nov 12 at 3:37
Daniel Roy
154
154
add a comment |
add a comment |
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"
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
add a comment |
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"
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
add a comment |
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"
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
add a comment |
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"
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"
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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