R
Ray
Hi -
I've got some code that I've used in a previous workbook that allows a
user to save a file to specified drive, using info from the file
itself to build the file path and name. The previous version of the
code (way below) only used one variable in building the path/name,
while the current one uses 2 variables -- the addition of the 2nd
variable appears to be causing the problem...
The code below is my most recent attempt at making this work -- I've
already tried a bunch of different variations of the code:
Private Sub SubmitFcst_Click()
Dim Drive As Long
Dim Path As String, Per As String, Bus As String, NewPath As
String
Dim Store As String, NewFile As String, NewPath2 As String
Store = Format(Sheets("Dashboard").Range("E13").Value, "000")
Bus = Sheets("Dashboard").Range("J15").Value
Per = Sheets("Dashboard").Range("i5").Value
Path = "\\....\Store Forecasts\FY08\" 'actual code specifies
entire drive path
NewPath = Path & Per & "\"
NewPath2 = NewPath & Bus & "\"
NewFile = NewPath2 & "Forecast_" & Bus & Store & "_" & Per &
".xls"
' <misc code used to verify user's intent to save remotely and ensure
all necessary info is entered>
'Make folder to hold new Forecast file
If Dir(NewPath2, vbDirectory) = "" Then MkDir NewPath2
' the line above gives an Error 76: unable to find
specified path, with the Mkdir code highlighted ... I also tried MkDir
(NewPath2) ...
ORIGINAL code:
If Dir(Path & Per, vbDirectory) = "" Then MkDir (Path & Per)
Is there a limit to how many variables can be used in building the
filename?
All help is greatly appreciated ....
//ray
I've got some code that I've used in a previous workbook that allows a
user to save a file to specified drive, using info from the file
itself to build the file path and name. The previous version of the
code (way below) only used one variable in building the path/name,
while the current one uses 2 variables -- the addition of the 2nd
variable appears to be causing the problem...
The code below is my most recent attempt at making this work -- I've
already tried a bunch of different variations of the code:
Private Sub SubmitFcst_Click()
Dim Drive As Long
Dim Path As String, Per As String, Bus As String, NewPath As
String
Dim Store As String, NewFile As String, NewPath2 As String
Store = Format(Sheets("Dashboard").Range("E13").Value, "000")
Bus = Sheets("Dashboard").Range("J15").Value
Per = Sheets("Dashboard").Range("i5").Value
Path = "\\....\Store Forecasts\FY08\" 'actual code specifies
entire drive path
NewPath = Path & Per & "\"
NewPath2 = NewPath & Bus & "\"
NewFile = NewPath2 & "Forecast_" & Bus & Store & "_" & Per &
".xls"
' <misc code used to verify user's intent to save remotely and ensure
all necessary info is entered>
'Make folder to hold new Forecast file
If Dir(NewPath2, vbDirectory) = "" Then MkDir NewPath2
' the line above gives an Error 76: unable to find
specified path, with the Mkdir code highlighted ... I also tried MkDir
(NewPath2) ...
ORIGINAL code:
If Dir(Path & Per, vbDirectory) = "" Then MkDir (Path & Per)
Is there a limit to how many variables can be used in building the
filename?
All help is greatly appreciated ....
//ray