sht.Activate
appExcel.Application.Visible = True
ErrorHandlerExit:
Exit Sub
ErrorHandler:
If Err = 429 Then
Excel is not running; open Excel with CreateObject:
Set appExcel = CreateObject(“Excel.Application”)
Resume Next
Else
MsgBox “Error No: “ & Err.Number & “; Description: “ &
Err.Description
Resume ErrorHandlerExit
End If
End Sub
If Excel is open, the workbook will be opened in the same window, as shown in Figure 7.6.
FIGURE 7.6
Opening a saved workbook in an existing Excel window.
Part II Writing VBA Code to Exchange Data between Office Components