Solved

Record an excel macro within vb app

Posted on 2002-05-06
6
148 Views
Last Modified: 2010-05-02
Is there a way to open an excel document into my app, and record a macro and save the macro like in office? I can increase the points if needed
0
Comment
Question by:damion69
6 Comments
 
LVL 3

Accepted Solution

by:
leojl earned 100 total points
ID: 6992036
hi,

I have a form in VB6 that I use to work with Excel
' this is in the general section of the form
Dim Eapp As Excel.Application
Dim Ebook As Excel.Workbook
Dim Esheet As Excel.Worksheet

'This starts Excel and shows sheet1
'sheet1 is the active sheet.
'now you can work directly with Excel and record a macro.

Private Sub mnuExcel_Click()
Set Eapp = New Excel.Application
Set Ebook = Eapp.Workbooks.Add
Eapp.Visible = True
End Sub

'I you do not wish to save Excel click here
Private Sub mnuNothing_Click()
Eapp.Quit
Set Eapp = Nothing
End Sub

leo
0
 
LVL 3

Expert Comment

by:leojl
ID: 6992084
hi again,

In VB design mode you should click on the
Project Menu, then click Referances
then scroll to Microsoft Excel 9.0 Object Library
check the box and click OK.

I have Office 2000 which has 9.0..
You might have a different number.

leo
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6992201
Basically, what leojl saids is true, do you need in other way?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 3

Expert Comment

by:leojl
ID: 6992551
hi yet again,

Richie, I would appreciate seeing another approach.
Perhaps more sophisticated to first check if there is
a running Excel and also to deal with possible errors.

leo
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6992842
0
 
LVL 2

Author Comment

by:damion69
ID: 7214554
Thank you for this. Sorry it took so long, I am no longer on the project that needed that.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

856 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