sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 585
- Office Version
- 365
- Platform
- 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
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