?
Solved

How to run Excel Macros from VB6

Posted on 2001-06-03
5
Medium Priority
?
352 Views
Last Modified: 2011-09-20
Dear All,

I need someone to point me in the right direction on how to solve my problem, which is:

I have an Excel Template (I created) which includes some Macors written in VBA (I wrote them), I would like my program in VB to open this Excel Template and run the macros in it. Any idea to get me going?
0
Comment
Question by:khaledc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
q2eddie earned 200 total points
ID: 6151295
Hi, khaledc.

<--------------- Sample Code Begins ------------->
Dim tmpSheet As Object
Set tmpSheet = CreateObject("excel.application")
' Set this to true only if you want to see the macro run.
tmpSheet.Visible = True
' Open the Excel spreadsheet file.
' Remember: AutoOpen will NOT execute if you
'           open the spreadsheet this way.
tmpSheet.workbooks.open "c:\temp\test_macro.xls"
' Run the macro.
tmpSheet.run "Macro1"
' You can close the spreadsheet.
' Note: "False" means that the spreadsheet will
'       close without warning.
'tmpSheet.workbooks("test_macro.xls").Close False
<--------------- Sample Code Begins ------------->

Bye. -e2
0
 
LVL 1

Author Comment

by:khaledc
ID: 6151391
-e2,

Will the excel sheet open be a subject of the VB?

In any case, I will try your suggestion and get back at you ASAP.

Cheers,
0
 
LVL 1

Author Comment

by:khaledc
ID: 6151429
I think I am on the right track now.

Cheers,
0
 
LVL 7

Expert Comment

by:q2eddie
ID: 6151435
Hi, again.

>Will the excel sheet open be a subject of the VB?
Did you have further questions about this is or are you at the point where you can continue?

Bye. -e2
0
 
LVL 1

Author Comment

by:khaledc
ID: 6151510
-e2

I will be alright.

Cheers.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question