BigtunaExcel
New Member
- Joined
- Apr 26, 2022
- Messages
- 7
- Office Version
- 365
I have a VBA script for Outlook that works fine on my machine however when I paste code into my coworkers application parts of the code turns red and the error message says "Syntax Error". I tried this on a handful of machines and repeated get the same red font errors. I don't think it is reference issue, and I don't think it is a macro security issue either, but that this point any suggestions for things to try would be greatly appreciated.
Private Sub GetPDFS(mostrecentdate As Date, Optional foldername As String, Optional subfoldername As String)
Dim Inbox As Outlook.MAPIFolder
Dim Item As Outlook.MailItem
Dim Atmt As Outlook.Attachment
Dim fileName As String
Dim i As Integer
Dim subject As String
Dim ws_test As Integer
Dim attachment_counter As Integer
Dim received As Date
Dim testDate As Date
Dim NS As Outlook.Namespace
Dim objOwner As Outlook.Recipient
Set NS = GetNamespace("MAPI")
Set objOwner = NS.CreateRecipient(Sample@sample.us.com)
objOwner.Resolve
'' See if subfolder has name.
If foldername = "" Then
Set Inbox = NS.GetSharedDefaultFolder(objOwner, olFolderInbox)
ElseIf subfoldername = "" Then
Set Inbox = NS.GetSharedDefaultFolder(objOwner, olFolderInbox).Folders(foldername)
Else
Set Inbox = NS.GetSharedDefaultFolder(objOwner, olFolderInbox).Folders(foldername).Folders(subfoldername)
End If
i = 1
received = mostrecentdate + 1
'' This is based on the idea that Inbox.Items is sorted by recieved date.
Dim ct As Integer
Dim pol As String
Dim savename As String
Do While received > mostrecentdate
Set Item = Inbox.Items(i)
received = Item.ReceivedTime
senderemail = Item.Sender
If senderemail = XXXX Or senderemail = "XXX" Or senderemail = "XX" Then
subject = Item.subject
subject = removeSpecial(subject)
Body = Item.Body
Private Sub GetPDFS(mostrecentdate As Date, Optional foldername As String, Optional subfoldername As String)
Dim Inbox As Outlook.MAPIFolder
Dim Item As Outlook.MailItem
Dim Atmt As Outlook.Attachment
Dim fileName As String
Dim i As Integer
Dim subject As String
Dim ws_test As Integer
Dim attachment_counter As Integer
Dim received As Date
Dim testDate As Date
Dim NS As Outlook.Namespace
Dim objOwner As Outlook.Recipient
Set NS = GetNamespace("MAPI")
Set objOwner = NS.CreateRecipient(Sample@sample.us.com)
objOwner.Resolve
'' See if subfolder has name.
If foldername = "" Then
Set Inbox = NS.GetSharedDefaultFolder(objOwner, olFolderInbox)
ElseIf subfoldername = "" Then
Set Inbox = NS.GetSharedDefaultFolder(objOwner, olFolderInbox).Folders(foldername)
Else
Set Inbox = NS.GetSharedDefaultFolder(objOwner, olFolderInbox).Folders(foldername).Folders(subfoldername)
End If
i = 1
received = mostrecentdate + 1
'' This is based on the idea that Inbox.Items is sorted by recieved date.
Dim ct As Integer
Dim pol As String
Dim savename As String
Do While received > mostrecentdate
Set Item = Inbox.Items(i)
received = Item.ReceivedTime
senderemail = Item.Sender
If senderemail = XXXX Or senderemail = "XXX" Or senderemail = "XX" Then
subject = Item.subject
subject = removeSpecial(subject)
Body = Item.Body