I want to save an excel file.
-The file’s name and folders’s names will change each time a file is saved.
-I recorded a macro to save the current file, then added variables defined by InputBoxes so a user could name and save each file to the correct folder.</SPAN>
I get the error message when using the variables. I'm not seeing what I'm doing incorrectly, or if I've used too many variables, or if the script can be edited further to include additional functions which would strengthen it.
Thanks in advance!
QUESTION
Is there a limit to the number of variables (DIM) set?</SPAN>
When saving files to folders whose names for each change, does using variables (DIM) cause issues? Can the issue be resolved?</SPAN>
-The file’s name and folders’s names will change each time a file is saved.
-I recorded a macro to save the current file, then added variables defined by InputBoxes so a user could name and save each file to the correct folder.</SPAN>
I get the error message when using the variables. I'm not seeing what I'm doing incorrectly, or if I've used too many variables, or if the script can be edited further to include additional functions which would strengthen it.
Thanks in advance!
Code:
Dim WkMnth As String</SPAN>
Dim WkNumber As Integer</SPAN>
Dim WkFull As String</SPAN>
WkMnth = InputBox(Prompt:="What is the MONTH?, Title:="Week Month")</SPAN>
WkNumber = InputBox(Prompt:="What is the WEEK?, Title:="Week Number")</SPAN>
WkFull = WkMnth & " Week " & WkNum</SPAN>
Dim WeekYr As Integer</SPAN>
Dim xSystem As String</SPAN>
WeekYr = InputBox(Prompt:="What is the year?, Title:="Name the Year")</SPAN>
xSystem = InputBox(Prompt:="What is the System?", Title:="Name of System")</SPAN>
Dim WkMonthNum As Integer</SPAN>
If WkMonth = "Jan" Then</SPAN>
WkMonthNum = "01"</SPAN>
ElseIf WkMonth = "Feb" Then</SPAN>
WkMonthNum = "02"</SPAN>
End If</SPAN>
ActiveWorkbook.SaveAs FileName:="Z:\ParentFolder\SubFolderNameOne " & WeekYr & " " & WkMonthNum & _</SPAN>
"\SubFolderNameTwo " & xSystem & " " & WeekYr & " " & WkMonthNum & _</SPAN>
"\FileName Complete_" & xSystem & " " & WeekYr & " " & WkMonth & " Week " & WkNumber & ".xlsx" _</SPAN>
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
QUESTION
Is there a limit to the number of variables (DIM) set?</SPAN>
When saving files to folders whose names for each change, does using variables (DIM) cause issues? Can the issue be resolved?</SPAN>
Last edited: