VBA was Excel98 now Excel 2004

F

Francesca

Using my VBA (made in Excel98) in Excel 2004 I have one problem I cannot
resolve.
At: "ActiveWorkbook.Close" The error says: "Laufzeitfehler 1004, The
method 'Close' for the Objekt 'workbook' does not work.

I worked with these VBA for years, (since I have Office98) very well.
I saved the Workbooks new in Excel 2004 to make them real "Excel2004
Workbooks" the problem seemed vanished after doing thisin december 2004
an January 2005, but now the problem appears again. I cannot use Excel 2004.

I send you following the "auto_open sub"
The user starts with this. It opens the Workbook "SteuernZHNP.xls" on
which the user sees several Buttons.
If he chooses the button "Neueröffnung" he starts the sub Neueröffnung.
The Start of this sub I also send you.

At the moment of:

Windows(name_stzh).Activate '"SteuernZHNP.xls"
ActiveWorkbook.Close
or:

If (Application.Dialogs(xlDialogSaveAs).Show) = False Then

Application.DisplayAlerts = False
ActiveWorkbook.Close

The error appears in excel 2004 for OSX.

Here come the sub:

---------------------------------------
Public pfad_stzh
Public name_stzh
Public name_sten
Public pfad_sten
Public bsystem

Sub Auto_Open()

bsystem = InStr(1, Application.OperatingSystem, "win", vbTextCompare)

Application.ScreenUpdating = False
Application.DisplayAlerts = False


Windows("T2004.xls").Visible = False


name_stzh = "SteuernZHNP.xls"
pfad_stzh = pfad_ordner + Application.PathSeparator + name_stzh
Workbooks.Open Filename:=pfad_stzh

'ActiveWindow.WindowState = xlNormal
name_sten = "StEN2004.xls"
pfad_sten = pfad_ordner + Application.PathSeparator + name_sten
On Error Resume Next

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
----------------------------------------

Sub Neueröffnung()

Dim Antwort
Antwort = MsgBox("Speichere die Datei mit dem Namen des Kunden in den
richtigen Ordner! Beispiel: D 2004 Name Vorname",
vbOKCancel, "Taxintosh® Sicherungsdatei für Neukunde")
If Antwort = vbCancel Then
Exit Sub
End If

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Windows(name_stzh).Activate '"SteuernZHNP.xls"
ActiveWorkbook.Close


Application.ScreenUpdating = False
Application.DisplayAlerts = False

With Application
.SheetsInNewWorkbook = 1
End With

Workbooks.Add
ActiveWorkbook.SaveAs Filename:="D 2004 Name Vorname",
FileFormat:=xlText, _
CreateBackup:=False


'Sichern unter ....
If (Application.Dialogs(xlDialogSaveAs).Show) = False Then

Application.DisplayAlerts = False
ActiveWorkbook.Close

Workbooks.Open Filename:=pfad_stzh
 
Top