VBA

Moderators: PavlinII
Number of threads: 1614
Number of posts: 3000

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
VBA for Excel question (VB6) Posted by pedestrian on 16 Apr 2006 at 7:10 PM
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.
Regards,
Pedestrian
------------------- The Code ----------------

Option Explicit
Dim myApp As Excel.Application

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

myApp.Cells(1, 1).Value = "Hello"
End Sub
Report
Re: Solution found Posted by pedestrian on 20 Apr 2006 at 11:43 PM
I've found the solution... thanks for viewing



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.