ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Concatenating Variables into file path name (https://www.excelbanter.com/excel-programming/279761-concatenating-variables-into-file-path-name.html)

Ron[_13_]

Concatenating Variables into file path name
 
I can't seem to place a variable in the file path, other
than the file name at the end of the path. I've tested the
code with text rather thn the variable, but when I try to
reference a cell for a text value, I get a "cannot find
path" error. What is the syntax for adding a variable in
the middle of the path?

E.g.

ActiveWorkbook.SaveAs FileName:="E:\subfldr1\subfldr2\" &
ActiveSheet.Range("E25")& "\Subfldr4\"& stFileName

steve

Concatenating Variables into file path name
 
Ron,

First check that E25 has a valid text folder name.
Second try ActiveSheet.Range("E25").Text
Third make sure there are spaces on each side of the &
And lastly make sure your code is on a single line, or use the line
continuation symbol _

Double check by using a message box
MSGBOX "E:\subfldr1\subfldr2\" & _
ActiveSheet.Range("E25").Text & "\Subfldr4\" & stFileName
--
sb
"Ron" wrote in message
...
I can't seem to place a variable in the file path, other
than the file name at the end of the path. I've tested the
code with text rather thn the variable, but when I try to
reference a cell for a text value, I get a "cannot find
path" error. What is the syntax for adding a variable in
the middle of the path?

E.g.

ActiveWorkbook.SaveAs FileName:="E:\subfldr1\subfldr2\" &
ActiveSheet.Range("E25")& "\Subfldr4\"& stFileName





All times are GMT +1. The time now is 05:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com