Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error in VBA code to save workbook

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
can not save if this code is in the workbook jlclyde Excel Discussion (Misc queries) 0 December 17th 08 10:21 PM
[Q] Save As throws type mismatch error in control's code? Jason Weiss Excel Discussion (Misc queries) 1 July 16th 05 04:21 AM
Error in VBA code to save workbook pikus Excel Programming 1 April 29th 04 03:21 PM
Automatically run VB code on workbook save event Tim[_32_] Excel Programming 2 December 10th 03 08:06 PM
VBA code to save gives error 1004??? Richard m Excel Programming 1 November 26th 03 04:10 AM


All times are GMT +1. The time now is 10:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"