G
Guest
Hi all,
Thanks in advance.
Closing an saving an appliaction but can't close or save it without a dialog
box.
What is wrong with the code?
Dim obj As Object
On Error Resume Next
'-- Set up excel
Set obj = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
'-- Excel Was Not Running So Start New Instance
Set obj = CreateObject("Excel.Application")
End If
With obj
.Workbooks.Open FileName:="C:\39104A.xls"
'-- Set up header row
.Application.Visible = True
'select first sheet only
.Sheets(1).Select
.Columns("K:IV").Select
.Selection.Delete Shift:=xlToLeft
.workbook.Close SaveChanges:=True 'is this correct?
.workbook.Save SaveChanges:=True 'is this correct?
'.Close SaveChanges:=True 'is this correct?
.Quit 'is this
correct?
End With
obj.Close
Set obj = Nothing
Once again thanks
Trev.
PS I have tried all combinations of close, quit & save but can't get it right.
Thanks in advance.
Closing an saving an appliaction but can't close or save it without a dialog
box.
What is wrong with the code?
Dim obj As Object
On Error Resume Next
'-- Set up excel
Set obj = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
'-- Excel Was Not Running So Start New Instance
Set obj = CreateObject("Excel.Application")
End If
With obj
.Workbooks.Open FileName:="C:\39104A.xls"
'-- Set up header row
.Application.Visible = True
'select first sheet only
.Sheets(1).Select
.Columns("K:IV").Select
.Selection.Delete Shift:=xlToLeft
.workbook.Close SaveChanges:=True 'is this correct?
.workbook.Save SaveChanges:=True 'is this correct?
'.Close SaveChanges:=True 'is this correct?
.Quit 'is this
correct?
End With
obj.Close
Set obj = Nothing
Once again thanks
Trev.
PS I have tried all combinations of close, quit & save but can't get it right.