R
rsmith
Whats the code for executing a macro contained inside a workbook ?
So far this is what I have :
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRng As Excel.Range
' Start Excel and get Application object.
oXL = CreateObject("Excel.Application")
oXL.Visible = True
oWB = oXL.Workbooks.Open("C:\Documents and _
Settings\Smith\Desktop\Book1.xls")
oSheet = oWB.ActiveSheet
' Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = "First Name"
oSheet.Cells(1, 2).Value = "Last Name"
oSheet.Cells(1, 3).Value = "Full Name"
oSheet.Cells(1, 4).Value = "Salary"
' ??? What will execute Macro1 in object oWB ???
Also, if I want to import a module into a workbook and execute
the Macros contained within, what would be the code for this ?
So far this is what I have :
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRng As Excel.Range
' Start Excel and get Application object.
oXL = CreateObject("Excel.Application")
oXL.Visible = True
oWB = oXL.Workbooks.Open("C:\Documents and _
Settings\Smith\Desktop\Book1.xls")
oSheet = oWB.ActiveSheet
' Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = "First Name"
oSheet.Cells(1, 2).Value = "Last Name"
oSheet.Cells(1, 3).Value = "Full Name"
oSheet.Cells(1, 4).Value = "Salary"
' ??? What will execute Macro1 in object oWB ???
Also, if I want to import a module into a workbook and execute
the Macros contained within, what would be the code for this ?