breakingme10
New member
- Local time
- Today, 10:53
- Joined
- Apr 18, 2014
- Messages
- 5
I have found this old post "1237140" (I can't post actual links because my post count is 0, that's the post number in the hyperlink, I normally use accessforums.net for all my problems, but since this is where I found the most relevant albeit unanswered information).
It was never answered and I'm having a similar problem.
I have written a module in VBA that has a subroutine for generating an outlook meeting, it works until I try and add an attachment. The above post says that the attachment property is read-only. Does this mean we cannot an attachments to a meeting through VBA?
My attachment was coming from a text box containing the full file path.
Here is my module and in my form's module, I have set the values for the public variables.
As you can see, I've commented out the attachment portion. As long as I leave it out, the code works great. If I uncomment that or do any other variation of trying to use .attachment at all, it fails. If I try .Attachment.Add I get "Argument Not Optional".
It was never answered and I'm having a similar problem.
I have written a module in VBA that has a subroutine for generating an outlook meeting, it works until I try and add an attachment. The above post says that the attachment property is read-only. Does this mean we cannot an attachments to a meeting through VBA?
My attachment was coming from a text box containing the full file path.
Here is my module and in my form's module, I have set the values for the public variables.
As you can see, I've commented out the attachment portion. As long as I leave it out, the code works great. If I uncomment that or do any other variation of trying to use .attachment at all, it fails. If I try .Attachment.Add I get "Argument Not Optional".
Code:
Option Compare Database
Public oSendTo As String
Public oSubject As String
Public oBody As String
Public oLocation As String
Public oStartDate As String
Public oStartTime As String
Public oEndDate As String
Public oEndTime As String
Public oFullDay As Boolean
Public oAtt As String
Public Sub GenerateMeeting()
On Error GoTo Err_Handler
Dim oOut As New Outlook.Application
Dim oApp As AppointmentItem
Dim oExp As Outlook.Explorer
Set oOut = New Outlook.Application
Set oApp = oOut.CreateItem(olAppointmentItem)
Set oExp = oOut.Session.GetDefaultFolder(olFolderInbox).GetExplorer
With oApp
.OptionalAttendees = "Cal Invites;" & oSendTo
.Recipients.ResolveAll
.Subject = oSubject
.Location = oLocation
.Start = DateValue(oStartDate) & " " & TimeValue(oStartTime)
.End = DateValue(oEndDate) & " " & TimeValue(oEndTime)
.ReminderSet = False
.BusyStatus = olFree
.BodyFormat = olFormatHTML
.Body = oBody
.AllDayEvent = oFullDay
.MeetingStatus = olMeeting
.ResponseRequested = True
'If Not IsNull(oAtt) Then
' .Attachments.Add = oAtt
'End If
.Display
End With
Exit_Handler:
Set oExp = Nothing
Set oApp = Nothing
Set oOut = Nothing
Exit Sub
Err_Handler:
If Err.Number = 0 Then
Resume Next
Else
MsgBox Err.Number & ": " & Err.Description & vbCrLf & Err.Source, vbOKOnly, "ERROR"
Resume Exit_Handler
End If
End Sub