Early binding issue, reference to Microsoft Excel not working

Bering

Board Regular
Joined
Aug 22, 2018
Messages
186
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have this macro that is stored in Microsoft Outlook to send out emails, it works perfectly fine for me but not for my new colleague.

The only requirement is to have the excel file LOG 2.xlsm open before running it.

For my colleague it stops here and will not work unless she restarts her PC.


Code:
Set wb = myXL.Workbooks("LOG 2.xlsm") '<-- Wb already open. Rename as appropriate

The file is saved in the same location for all of us and she is using the same version of Excel.

I am using the below references:

Visual Basic for Applications
Microsoft Outlook 16.0 Object Library
Microsoft Office 16.0 Object Library
Microsoft Excel 16.0 Object Library
Microsoft Scripting Runtime
Accessibility CpIAdmin 1.0 Type Library


Any idea is much appreciated!! Thank you


VBA Code:
Option Explicit
Sub Send_Email_to_Investors()
Dim olMsg As MailItem
    
    Set olMsg = ActiveExplorer.Selection.Item(1)
    Email_to_Investors
lbl_Exit:
    Set olMsg = Nothing
    Exit Sub
End Sub
Sub Email_to_Investors()
    
     Dim myMail As Outlook.MailItem
     Dim wb As Excel.Workbook 'Early bind - needs a reference to Excel
     Dim myXL As Excel.Application 'Early bind - needs a reference to Excel
     Dim mySh As Worksheet
     Dim myBody, Signature, sPath As String, strFile As String, strFolderPath As String, ext As String
     Dim oAttachments As Outlook.Attachments
     Dim StrSignature, signImageFolderName, completeFolderPath As String
     Dim strLocation, strFileName, strFileExt, strFileName1, strFileExt1, pass As String
     Dim i As Long, fCol As Long, lCol As Long, iCount As Long
     Dim stExport As Variant
     Dim sFolder As String
     Dim aFolders() As Variant
     Dim iFolderCount As Integer

    
        
     Set myXL = GetObject(, "Excel.Application") 'Excel already running
     Set wb = myXL.Workbooks("LOG 2.xlsm") '<-- Wb already open. Rename as appropriate
 
If you use the full path with getobject it will grab the correct workbook, and open it if required.
Thanks, so far still no luck. Our IT people think there might be a conflict with other pre-installed add ins (Bloomberg for example). Still under investigation… I’ll post the solution if someone figures it out. Thanks
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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