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
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Does she get an error? If so, what is the message?
 
Upvote 0
I get that error if i have more than one spreadsheet open.

How many instances of Excel are open when you run the code in Outlook?
 
Upvote 0
I get that error if i have more than one spreadsheet open.

How many instances of Excel are open when you run the code in Outlook?
Thank you. We tried with just one spreadsheet open, but she still got the issue. Only restarting seems to fix the issue..
 
Upvote 0
Do you have any code in any other files that are used that may make an instance of Excel not visible at any point?
 
Upvote 0
Do you have any code in any other files that are used that may make an instance of Excel not visible at any point?
no, I don't think so but I will double check that. Thank you

EDIT: perhaps using the full path could fix the issue?
 
Upvote 0
Could also see if you get a different result if you open the xlsm file from the VBA rather than having it open already?
 
Upvote 0
If you use the full path with getobject it will grab the correct workbook, and open it if required.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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