CyberJar
Apr 20th, 2004, 07:23 AM
Hello,
My Excel 97/VBA is executed online from a web server.
Two things are wrong with my Save Routine:
1. I do a Worksheet.Copy, Save it, Close it, and Retun to ThisWorkbook.
The problem is after this executes there is a big empty Window named "Microsoft Excel [Read-only]" which has the focus. My guess is that a new window is opened to create a new Workbook, then copies the Worksheet in. After Saving & Closing, only the empty window is left. If I close this empty window, my Application stops. My Application is running in a separate Window.
2. In the debugger, I see that "Application.ScreenUpdating = False" never gets set to False. Odd!
Here is the Save Routine:
Private Sub cmdSave_Click()
Dim varFileName As Variant
On Error GoTo 300
ChDir "C:\"
Do
varFileName = Application.GetSaveAsFilename("My Report", "Excel File(*.xls),*.xls", , "Save My Report")
Loop Until varFileName <> False
If (VarType(varFileName) = vbString) Then
Application.ScreenUpdating = False
objMyWS.Copy
ActiveWorkbook.SaveAs FileName:=varFileName, FileFormat:=xlWorkbookNormal
ActiveWorkbook.Close savechanges:=False
ThisWorkbook.Activate
Application.ScreenUpdating = True
End If
objMyWS.Activate
Exit Sub
300:
MsgBox Err.Number & " " & Err.Description
Resume Next
End Sub
The question is, How do I remove the big empty Window and stop it from receiving focus? I would like that window to go away after the Workbook is closed. Why does "ScreenUpdating = False" fail? I need the WkSheet to refresh itself after line deletion (in another section of code).
It works fine offline, but once online - all rules change.
TIA,CJ
My Excel 97/VBA is executed online from a web server.
Two things are wrong with my Save Routine:
1. I do a Worksheet.Copy, Save it, Close it, and Retun to ThisWorkbook.
The problem is after this executes there is a big empty Window named "Microsoft Excel [Read-only]" which has the focus. My guess is that a new window is opened to create a new Workbook, then copies the Worksheet in. After Saving & Closing, only the empty window is left. If I close this empty window, my Application stops. My Application is running in a separate Window.
2. In the debugger, I see that "Application.ScreenUpdating = False" never gets set to False. Odd!
Here is the Save Routine:
Private Sub cmdSave_Click()
Dim varFileName As Variant
On Error GoTo 300
ChDir "C:\"
Do
varFileName = Application.GetSaveAsFilename("My Report", "Excel File(*.xls),*.xls", , "Save My Report")
Loop Until varFileName <> False
If (VarType(varFileName) = vbString) Then
Application.ScreenUpdating = False
objMyWS.Copy
ActiveWorkbook.SaveAs FileName:=varFileName, FileFormat:=xlWorkbookNormal
ActiveWorkbook.Close savechanges:=False
ThisWorkbook.Activate
Application.ScreenUpdating = True
End If
objMyWS.Activate
Exit Sub
300:
MsgBox Err.Number & " " & Err.Description
Resume Next
End Sub
The question is, How do I remove the big empty Window and stop it from receiving focus? I would like that window to go away after the Workbook is closed. Why does "ScreenUpdating = False" fail? I need the WkSheet to refresh itself after line deletion (in another section of code).
It works fine offline, but once online - all rules change.
TIA,CJ