Record an excel macro within vb app

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
LVL 2
damion69Asked:
Who is Participating?
 
leojlConnect With a Mentor Commented:
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
 
leojlCommented:
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
 
Richie_SimonettiIT OperationsCommented:
Basically, what leojl saids is true, do you need in other way?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
leojlCommented:
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
 
n_narayananCommented:
0
 
damion69Author Commented:
Thank you for this. Sorry it took so long, I am no longer on the project that needed that.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.