Results 1 to 4 of 4

Thread: Macro does not work on other Outlook client

  1. #1
    VBAX Newbie
    Mar 2023

    Macro does not work on other Outlook client


    I've a working VBA code (see att). What is does: Selecting one or more received mail items in Outlook and the macro put a TAG in front of the subject field on every selected mail item. Then every selected item is forwarded to a specific mail adres.

    Sub ForwardSelectedItems()
    Dim forwardmail As MailItem
    Dim itm As Object
    Dim Xsubject As String
    Dim itmSel As Selection
    Dim n As Long
    Set itmSel = ActiveExplorer.Selection
    n = itmSel.Count
    Do While n > 0
        Set itm = itmSel.Item(n)
        Xsubject = itm.Subject
        If itm.Class = olMail Then
            Set forwardmail = itm.Forward
            forwardmail.Subject = "[TAG] " & Xsubject
        End If
        n = n - 1
    End Sub
    The code works fine on one outlook client. Same macro on other pc outlook gives an error "Compile error: Syntaxerror".

    On both outlook clients the object library reference "Microsoft Outlook 16.0 Object Library" is selected.
    Attached Files Attached Files
    Last edited by Aussiebear; 01-17-2024 at 03:50 PM. Reason: Added the code directly to the post

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Dec 2005
    Welcome to VBAX Erka. I've taken the liberty to add your code directly to the post.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    First thing I would check is to make sure each PCs are running the exact same version of Outlook. Even if they are referencing the same object, the Outlook application itself may cause issues if they're far apart version wise.

  4. #4
    The "Compile error: Syntax error" that you are encountering when running the VBA code on a different Outlook client may be due to a difference in the version of Microsoft Outlook or a difference in the VBA environment settings. Hello Neighbor

Posting Permissions

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