BadgerLikeSpeed
Registered User.
- Local time
- Today, 00:24
- Joined
- Feb 7, 2013
- Messages
- 35
Hello again...
More questions! I have a relatively complicated excel workbook where the information is pulled from data from an excel book created from multiple queries. That sounds a lot more complicated than it is, but basically to get the data into the required format my final book links to various cells in the book created by access.
I've written the code to export everything and open the final sheet, which updates my data ok. What I need help with is then saving the final book with a new file name (preferably the date of the report, which is in a text box in a form), close the master copy of my book, and then break the links in the filled version of the book.
Basically:
1) Export data to Temp.xlsx <-- Already achieved
2) Open Master.xlsx <-- Already achieved
3) Save a copy of Master.xlsx as [ReportDate]Report.xlsx
4) Break links in [ReportDate]Report.xlsx
5) Delete Temp.xlsx (Kill Temp.xlsx?)
5) Close Excel
I get a run time error 438 at the Save as command, Object does not support this property or method.
I've found the ActiveWorkbook.BreakLink command, but I'm not sure how to use it, and also I need to be certain that it's not the master sheet where the links are broken.
Just to clarify, I'm running all of this out of my access database. I have a command button that takes a date from a form, runs a set of queries based on that date, and then exports it.
Any help would be massively appreciated!
More questions! I have a relatively complicated excel workbook where the information is pulled from data from an excel book created from multiple queries. That sounds a lot more complicated than it is, but basically to get the data into the required format my final book links to various cells in the book created by access.
I've written the code to export everything and open the final sheet, which updates my data ok. What I need help with is then saving the final book with a new file name (preferably the date of the report, which is in a text box in a form), close the master copy of my book, and then break the links in the filled version of the book.
Basically:
1) Export data to Temp.xlsx <-- Already achieved
2) Open Master.xlsx <-- Already achieved
3) Save a copy of Master.xlsx as [ReportDate]Report.xlsx
4) Break links in [ReportDate]Report.xlsx
5) Delete Temp.xlsx (Kill Temp.xlsx?)
5) Close Excel
Code:
Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open LPath & "GasReportBlank.xlsx"
'Save as...
xlApp.SaveAs LPath & "GasReport.xlsx"
xlApp.Quit
Set xlApp = Nothing
I get a run time error 438 at the Save as command, Object does not support this property or method.
I've found the ActiveWorkbook.BreakLink command, but I'm not sure how to use it, and also I need to be certain that it's not the master sheet where the links are broken.
Just to clarify, I'm running all of this out of my access database. I have a command button that takes a date from a form, runs a set of queries based on that date, and then exports it.
Any help would be massively appreciated!