P
PK
Please Help! I have been running cirlcles with this one for 2 days!
My code below opens an existing spreadsheet (from an access 2002 form
button), does some formatting on two different tabs, then closes and saves
the spreadsheet.
Here is the problem: When it completes, there is still an EXCEL.EXE process
in Task Manager. Also If I try to open the spreadsheet, i get only the EXCEL
header (no spreadsheet). I then close that, and kill the EXCEL.EXE process,
and I can open the spreadsheet with no problems (and everything is formatted
properly)
TIA for any help you can provide!!!!
Code:
If fIsAppRunning("Excel") Then
Set objXL = GetObject(, "Excel.Application")
boolXL = False
Else
Set objXL = CreateObject("Excel.Application")
boolXL = True
End If
objXL.Application.Visible = False
objXL.Application.Workbooks.Open "MySpreadsheet.xls"
Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
.Application.ActiveWindow.Zoom = 75
.Application.ActiveWindow.WindowState = xlMaximized
.Application.Sheets("Summary").Select
.Application.Range("A1").Select
.Application.Range(Selection, Selection.End(xlToRight)).Select
With .Application.Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
.Application.Selection.Font.Bold = True
.Application.ActiveWindow.SplitRow = 0.764705882352941
.Application.ActiveWindow.FreezePanes = True
.Application.Columns("A:F").EntireColumn.AutoFit
.Application.Columns("B:F").Select
.Application.Selection.NumberFormat = "0%"
'second
tab-------------------------------------------------------------
.Application.Sheets("Supporting_Data").Select
.Application.ActiveWindow.Zoom = 75
.Application.Range("A1").Select
.Application.Range(Selection, Selection.End(xlToRight)).Select
With .Application.Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
.Application.Selection.Font.Bold = True
.Application.ActiveWindow.SplitRow = 0.764705882352941
.Application.ActiveWindow.FreezePanes = True
.Application.Columns("A:AB").EntireColumn.AutoFit
.Application.Columns("J:K").Select
.Application.Selection.ColumnWidth = 46
.Application.Range("A1").Select
.Application.Sheets("Summary").Select
.Application.Range("A1").Select
End With
objActiveWkb.Close savechanges:=True
If boolXL Then
objXL.Application.Quit
End If
Set objActiveWkb = Nothing
Set objXL = Nothing
My code below opens an existing spreadsheet (from an access 2002 form
button), does some formatting on two different tabs, then closes and saves
the spreadsheet.
Here is the problem: When it completes, there is still an EXCEL.EXE process
in Task Manager. Also If I try to open the spreadsheet, i get only the EXCEL
header (no spreadsheet). I then close that, and kill the EXCEL.EXE process,
and I can open the spreadsheet with no problems (and everything is formatted
properly)
TIA for any help you can provide!!!!
Code:
If fIsAppRunning("Excel") Then
Set objXL = GetObject(, "Excel.Application")
boolXL = False
Else
Set objXL = CreateObject("Excel.Application")
boolXL = True
End If
objXL.Application.Visible = False
objXL.Application.Workbooks.Open "MySpreadsheet.xls"
Set objActiveWkb = objXL.Application.ActiveWorkbook
With objActiveWkb
.Application.ActiveWindow.Zoom = 75
.Application.ActiveWindow.WindowState = xlMaximized
.Application.Sheets("Summary").Select
.Application.Range("A1").Select
.Application.Range(Selection, Selection.End(xlToRight)).Select
With .Application.Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
.Application.Selection.Font.Bold = True
.Application.ActiveWindow.SplitRow = 0.764705882352941
.Application.ActiveWindow.FreezePanes = True
.Application.Columns("A:F").EntireColumn.AutoFit
.Application.Columns("B:F").Select
.Application.Selection.NumberFormat = "0%"
'second
tab-------------------------------------------------------------
.Application.Sheets("Supporting_Data").Select
.Application.ActiveWindow.Zoom = 75
.Application.Range("A1").Select
.Application.Range(Selection, Selection.End(xlToRight)).Select
With .Application.Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
.Application.Selection.Font.Bold = True
.Application.ActiveWindow.SplitRow = 0.764705882352941
.Application.ActiveWindow.FreezePanes = True
.Application.Columns("A:AB").EntireColumn.AutoFit
.Application.Columns("J:K").Select
.Application.Selection.ColumnWidth = 46
.Application.Range("A1").Select
.Application.Sheets("Summary").Select
.Application.Range("A1").Select
End With
objActiveWkb.Close savechanges:=True
If boolXL Then
objXL.Application.Quit
End If
Set objActiveWkb = Nothing
Set objXL = Nothing