I'm doing some .vbs coding in which I want to open an existing template file, make some changes to it, and then 'save as' with the filename specified in cell B2.
Set objExcel = CreateObject("Excel.Application")
FileDirectory = "C:\Users\j128\Desktop\"
FileName = "TEMPLATE.xlsx"
Set objWorkbook = objExcel.Workbooks.Open(FileDirectory+FileName)
objExcel.Visible = True
objExcel.Cells(2,2).value = "Variable" 'Changes will occur in this section
ActiveWorkbook.SaveAs Filename = cells(2,2).value 'This is where problems occur
I realise I can already use Macros to name an Excel file with the value specified in a cell. However, I'm planning on using this .vbs file to name other document types using values specified in a spreadsheet.
Thanks for any help!
Apparently it might not be possible: How can I use the common Save As dialog from VBScript?
I've also tried using sendkeys to select 'Save as', though it falls apart when coming to name the new file.