+ Reply to Thread
Results 1 to 9 of 9

Macro to generate email fails on other computers but works on mine

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    196

    Macro to generate email fails on other computers but works on mine

    I have a macro that generates an email at the click of a button. It is on a workbook that is distributed to others who do the same thing I do but for differing regions. Obviously the macro works for me. But one of the others says it simply does nothing for her. I had her send me her up to date workbook and opened it on my computer and the macro ran as advertised. One of the others also runs the macro fine on his machine.

    I'm thinking the issue is somewhere in her Outlook or Windows Setting and isn't an Excel issue. Here is the code, if anyone sees anything wrong I'd appreciate the chance to learn from it. Thanks for looking.

    Sub RaEmail()
        On Error GoTo ErrHandler
        
        ' SET Outlook APPLICATION OBJECT.
        Dim objOutlook As Object
        Set objOutlook = CreateObject("Outlook.Application")
        
        ' CREATE EMAIL OBJECT.
        Dim objEmail As Object
        Set objEmail = objOutlook.CreateItem(olMailItem)
    
        With objEmail
            .To = Sheets("Remote SM").Range("U1").Value
            .CC = Sheets("Remote SM").Range("U2").Value & ";" & Sheets("Remote SM").Range("U3").Value & ";" & Sheets("Remote SM").Range("U4").Value
            '.BCC = "REGIONAL MANAGERS;"
            .Subject = UCase(Sheets("Remote SM").Range("A6").Value) & ": " & "OLD RA WARNING"
            .Body = Sheets("Remote SM").Range("A6").Value & " " & "has old or past due RA's as shown below." & vbNewLine & "Beginning in August we will not pull for anyone whose RA's are past due." & vbNewLine & "Please have the tech turn in the old or past due RA immediately so it can be picked up on the next truck headed back to the warehouse."
            '& vbNewLine & ThisWorkbook.Sheets("Remote SM").Range("RETURNS")
            .Display        ' Display the message in Outlook.
        End With
        
        ' CLEAR.
        Set objEmail = Nothing:    Set objOutlook = Nothing
            
    ErrHandler:
        '
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: Macro to generate email fails on other computers but works on mine

    Make sure the other computer has the outlook reference checked
    Attached Images Attached Images
    If you find the suggestion or solution helpful, please consider adding reputation to the post.

  3. #3
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    196

    Re: Macro to generate email fails on other computers but works on mine

    Quote Originally Posted by cubangt View Post
    Make sure the other computer has the outlook reference checked
    It does. It appears she’s got Win 7 where I have Win 10. I assume that means her version of Excel is close but not the same as mine. IT is getting her a new computer with matching specs as mine. Hopefully we’ll get more info then. Thanks for your suggestion. I appreciate the time you took to help out.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,997

    Re: Macro to generate email fails on other computers but works on mine

    Change this:
        Set objEmail = objOutlook.CreateItem(olMailItem)
    to this
        Set objEmail = objOutlook.CreateItem(0)
    I suspect that you created the code using early binding and then converted it to late binding. olMailItem is an Outlook Object model item reference and will not be interpreted on someone else's machine without the Outlook reference.
    Last edited by TMS; 07-28-2021 at 04:31 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    196

    Re: Macro to generate email fails on other computers but works on mine

    Quote Originally Posted by TMS View Post
    Change this:
        Set objEmail = objOutlook.CreateItem(olMailItem)
    to this
        Set objEmail = objOutlook.CreateItem(0)
    I suspect that you created the code using early binding and then converted it to late binding. olMailItem is an Outlook Object model item reference and will not be interpreted on someone else's machine without the Outlook reference.
    I’m afraid it didn’t make a difference. IT thinks it is due to a difference in our Windows versions as she’s on 7 and I’m on 10. That makes me think we might have close but not quite the same version of excel. Hopefully getting her a new computer with matching specs will fix the issue. I appreciated the bit of learning though. Thanks for your time and help.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,997

    Re: Macro to generate email fails on other computers but works on mine

    @MrPhil: is this resolved?

  7. #7
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    196

    Re: Macro to generate email fails on other computers but works on mine

    Quote Originally Posted by TMS View Post
    @MrPhil: is this resolved?
    Not just yet. We think now that it might be version differnces in her and my OS. IT is going to get her a new computer and we’ll see then.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    47,997

    Re: Macro to generate email fails on other computers but works on mine

    Does she use other workbooks with macros successfully?

  9. #9
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    196

    Re: Macro to generate email fails on other computers but works on mine

    Quote Originally Posted by TMS View Post
    Does she use other workbooks with macros successfully?
    Yes Sir. All the other macros in that workbook work fine for her. It's only the one email issue.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Script to send email works 1st time, fails 2nd time
    By Sabernethy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-11-2020, 08:06 AM
  2. [SOLVED] Excel Macro Runs on Some Computers, Not All- Stalls for computers where it fails to run
    By jamie.harris in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-25-2018, 04:54 PM
  3. [SOLVED] Prints perfect from other computers... not from mine
    By RustoChango in forum Excel General
    Replies: 13
    Last Post: 03-19-2017, 01:19 PM
  4. Macro works on some computers but on others it doesn't
    By SEBS_PARADISE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-16-2011, 04:35 PM
  5. Macro run fails, step through works.
    By SteveAlston in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2009, 11:37 PM
  6. Macro works fine on PC; fails on Mac
    By marlea in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2006, 04:35 PM
  7. [SOLVED] Macro works differently on different computers, same version of Ex
    By oscardwilde in forum Excel General
    Replies: 6
    Last Post: 12-28-2005, 07:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1