Cannot get one of my macros in Outlook to run

sspatriots

Well-known Member
Joined
Nov 22, 2011
Messages
572
Office Version
  1. 365
Platform
  1. Windows
The following code will execute fine from the VBA Editor. When I assign a button to it in Outlook, I cannot get it to run at all.

Sub OpenCOMMG2JobList()
Dim File$
Dim Xl As Object ' Excel.Application
Dim Wb As Object ' Excel.Workbook
Dim Ws As Object ' Excel.Worksheet
Dim Rn As Object ' Excel.Range

File = " " 'Put your file path.

On Error Resume Next
Set Xl = GetObject(, "excel.application")
On Error GoTo 0
If Xl Is Nothing Then Set Xl = New Excel.Application
Set Wb = Xl.Workbooks.Open(File)
Set Ws = Wb.Sheets(1)
Ws.Activate
Set Rn = Ws.Range("a1")
Rn.Activate
Xl.Visible = True
End Sub


If anyone has any experience with this and can shed light on it, I would greatly appreciate it. My other buttons that I have assigned code to will run just fine.


Thanks,

SS
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,215,086
Messages
6,123,031
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top