xangetzu
New Member
- Joined
- Oct 23, 2017
- Messages
- 3
Greetings.
I have a series of workbooks I navigate between using references to cells and built in VBA commands for file directory and such. In particular I have a Template document which I use to create new workbooks for a particular project, who's title changes as I build a particular report. When I use my macro to navigate back to my home file, opening that is easy but for closing the current workbook I am in, I have to manually edit the script in VBA to the file name. By default it is called Template.xlsb as that is the template file's name. Is there a way to make that string a reference to a cell like I use in opening workbooks. I have tried using the same method but I return an out of range error.
Sample code.
I have tried changing the last line to Workbooks.Close Filename:=Range("B6").Value (This cell contains the file name with extension) and I get a return that is out of range or there are the wrong number of arguments. Thinking that I may need to include some text, I took the extension out, and changed it to Workbooks.Close Filename:=Range("B6").Value & ".xlsb" but got the same error.
I have a series of workbooks I navigate between using references to cells and built in VBA commands for file directory and such. In particular I have a Template document which I use to create new workbooks for a particular project, who's title changes as I build a particular report. When I use my macro to navigate back to my home file, opening that is easy but for closing the current workbook I am in, I have to manually edit the script in VBA to the file name. By default it is called Template.xlsb as that is the template file's name. Is there a way to make that string a reference to a cell like I use in opening workbooks. I have tried using the same method but I return an out of range error.
Sample code.
Sub Open_Launcher()
'
' Open Launcher back up
'
'
'
Sheets("Navigation").Select
Workbooks.Open Filename:=Range("B3").Value & "\Launcher.xlsb"
Workbooks("Launcher.xlsb").Sheets("Home").Activate
Workbooks("Template.xlsb").Close SaveChanges:=True
End Sub
'
' Open Launcher back up
'
'
'
Sheets("Navigation").Select
Workbooks.Open Filename:=Range("B3").Value & "\Launcher.xlsb"
Workbooks("Launcher.xlsb").Sheets("Home").Activate
Workbooks("Template.xlsb").Close SaveChanges:=True
End Sub
I have tried changing the last line to Workbooks.Close Filename:=Range("B6").Value (This cell contains the file name with extension) and I get a return that is out of range or there are the wrong number of arguments. Thinking that I may need to include some text, I took the extension out, and changed it to Workbooks.Close Filename:=Range("B6").Value & ".xlsb" but got the same error.