Solved

Record an excel macro within vb app

Posted on 2002-05-06
6
149 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
[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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

756 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