Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to run code in a module from a macro command 1

Status
Not open for further replies.

belstoy

Technical User
May 31, 2005
37
US
I am trying to run the following code via a macro command, but I am not having any luck. Which command should I be using? Runcode or something else?

[Private Sub cmdExcel_Click()
On Error GoTo Err_cmdExcel_Click

Dim oApp As Object

Set oApp = CreateObject("Excel.Application")
oApp.Visible = True 'Only XL 97 supports UserControl Property
oApp.Workbooks.Open FileName:="S:\PERSONNEL\RGava\GSA Overnight Job\GSA OV Run"
.xls ""
oApp.Visible = True
On Error Resume Next
oApp.UserControl = True

Exit_cmdExcel_Click:
Exit Sub

Err_cmdExcel_Click:
MsgBox Err.Description
Resume Exit_cmdExcel_Click

End Sub]

Thanks,
Belstoy
 
Issued Resolved! I changed the sub to a Function.

Belstoy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top