Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Chris
I spoke too soon. In fact, the line you suggest there does execute, no problem and the macro carries on without generating any errors, however, the workbook Example.xls remains open and the changes made to it have not been saved. Any ideas what is happening here? No other workbooks show as being open, so I am not sure what active book is being saved and closed when that line executes.... ----- chris wrote: ---- try this: Sub Macro1( Workbooks.Open Filename:= "G:\XXX\Example.xls Application.Run ("Example.xls!SecondMacro" ActiveWorkbook.Close SaveChanges:=True End Su ----- djchristie wrote: ---- I am running the code below to open a second workbook, run a macro resident in that second workbook and then save and close it. However, the code breaks at the line "ActiveWorkbook.Save" with the Run-time error '1004': '[:]' cannot be accessed. The file may be read-only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be reponding The strange part is that once you enter the debugger, I can switch back to the Excel window and manually save/close the workbook with no issue. Any ideas Sub Macro1( Workbooks.Open Filename:= "G:\XXX\Example.xls Application.Run ("Example.xls!SecondMacro" ActiveWorkbook.Sav ActiveWindow.Clos End Su |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
can not save if this code is in the workbook | Excel Discussion (Misc queries) | |||
[Q] Save As throws type mismatch error in control's code? | Excel Discussion (Misc queries) | |||
Error in VBA code to save workbook | Excel Programming | |||
Automatically run VB code on workbook save event | Excel Programming | |||
VBA code to save gives error 1004??? | Excel Programming |