VBA for Excel question (VB6) - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


VBA for Excel question (VB6)

pedestrianpedestrian Posts: 10Member
The following code is a VB6 Standard EXE. I create an Excel app using
OLE Automation. I only want One Excel app to be opened at one time.
If the Excel app is already opened, I reuse it to update the cell value.

If the user close the Excel and re-click the Command1 button in the VB app, the app should create a fresh excel app. However, the code below show runtime error. How to check whether the user have close the Excel app created by VB? Please advise... Thanks.

P/S: Message wrongly posted to Basic messagebox instead of VBA.
------------------- The Code ----------------

Option Explicit
Dim myApp As Excel.Application

Private Sub Command1_Click()
If myApp Is Nothing Then
Set myApp = New Excel.Application
myApp.Visible = True
End If

myApp.Cells(1, 1).Value = "Hello"
End Sub


Sign In or Register to comment.