ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Call Excel Macro in VB.NET (https://www.excelbanter.com/excel-programming/350015-call-excel-macro-vbulletin-net.html)

mimoran

Call Excel Macro in VB.NET
 

I’m new to VB. Net and I’m trying to run an excel macro within a VB.Ne
Application
This is what I’m doing.
Open Excel Application with Macro (Personal.XLS)
Open New created Excel Book which needs to be formatted using macr
saved in Personal.XLS

I’m having problems calling the macro. Please help.

Here is my code

Dim objExcel As Ne
Microsoft.Office.Interop.Excel.ApplicationClass
Dim objExcel1 As Ne
Microsoft.Office.Interop.Excel.ApplicationClass

'open Personal Spreadsheet and make it visible
objExcel.Workbooks.Open("C:\PERSONALreports.XLS")
objExcel.Visible = True


'open Excel that needs to be formatted and make it visible t
user
objExcel1.Workbooks.Open("C:\Test.xls")
objExcel1.Visible = True

'run macro to format

objExcell2.ExecuteExcel4Macro("objExcell.ExecuteEx cel4MacroLate_Full")


'close open Access applications
objExcel.Quit()
objExcel1.Quit(

--
mimoranPosted from - http://www.officehelp.i



All times are GMT +1. The time now is 07:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com