Live-Forum - Die aktuellen Beiträge
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Prob with save/close. How to force it ?

Forumthread: Prob with save/close. How to force it ?

Prob with save/close. How to force it ?
09.05.2004 18:52:47
Greg
Hi,
I have a problem to close and save a workbook (ultra protected, made by some vba specialist. That s probably why i have that problem).
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 to force it to save and close without any message ?
Thanks for your help,
Greg
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Sub Macro1()
Workbooks.Open Filename:= _
"G:\XXX\Example.xls"
Application.Run ("Example.xls!SecondMacro")
ActiveWorkbook.Save
ActiveWindow.Close
End Sub

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Anzeige

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Prob with save/close. How to force it ?
09.05.2004 19:06:49
DieterB
Hi Greg,
maybe the Workbook where the 2nd Macro is running is not active?
You're opening the 2nd WB, but is it active too?
kind regards
DieterB
AW: Prob with save/close. How to force it ?
NE
Hi Greg,
just a test, try this one:

Sub Macro1()
SetAttr "G:\XXX\Example.xls", vbNormal
Workbooks.Open Filename:= _
"G:\XXX\Example.xls"
Application.Run ("Example.xls!SecondMacro")
ActiveWorkbook.Save
ActiveWindow.Close
End Sub

cu Nancy
Anzeige
;

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige