Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Old 02-26-2013, 10:23 AM   #1
BrotherBook
Newly Registered User
 
Join Date: Jan 2013
Posts: 43
Thanks: 7
Thanked 2 Times in 2 Posts
BrotherBook is on a distinguished road
Problem adding an attachment field to Outlook appointment

Hi-

I've created some VBA to add appointment information contained in my database to a user's outlook calendar. The code works perfectly until I tried to include an attachment in the appointment using an attachment field in my database. I've scoured Google and these forms to try and find a solution, but I have been unable to find anything. Below is my code which receives Run Time error 438, "Object does not support the property or method" when trying to run ".attachments.add (Me.Agenda)".

Code:
'Exit the procedure if the appointment has already been added
If Me.AddedToOutlook = True Then
MsgBox ("This appointment has already been added to Outlook.")
Exit Sub
'Add a new appointment
Else
    Dim objOutlook As Outlook.Application
    Dim objAppt As Outlook.AppointmentItem
    
    Set objOutlook = CreateObject("Outlook.Application")
    Set objAppt = objOutlook.CreateItem(olAppointmentItem)
    
    With objAppt
    .Start = Me.AppointmentDate & " " & Me.AppointmentTime
    .Duration = Me.Duration
    .Subject = [Forms]![Menu]![ProspectListing].Column(1) & " (" & Me.ContactName & ")"
    .Attachments.Add (Me.Agenda)
    .Body = BodyString
    .ReminderMinutesBeforeStart = 15
    .ReminderSet = True
    .Save
    .Close (olSave)
    End With
    'Release the AppointmentItem object variable.
    Set objAppt = Nothing
End If

'Release the Outlook object variable.
Set objOutlook = Nothing

'Set the AddedToOutlook flag, save the record, display a message.
Me.AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox ("Appointment added to Outlook")

BrotherBook is offline   Reply With Quote
Old 02-26-2013, 11:14 AM   #2
BrotherBook
Newly Registered User
 
Join Date: Jan 2013
Posts: 43
Thanks: 7
Thanked 2 Times in 2 Posts
BrotherBook is on a distinguished road
Re: Problem adding an attachment field to Outlook appointment

I have determined that the .attachments within the Appointment is just a read only property so that is why I have been getting the error. However, I haven't been able to get an attachment to pass through.
BrotherBook is offline   Reply With Quote
Old 02-27-2013, 02:49 AM   #3
pr2-eugin
Super Moderator
 
pr2-eugin's Avatar
 
Join Date: Nov 2011
Location: Bournemouth, UK
Posts: 8,498
Thanks: 68
Thanked 2,067 Times in 2,014 Posts
pr2-eugin has a spectacular aura about pr2-eugin has a spectacular aura about pr2-eugin has a spectacular aura about
Re: Problem adding an attachment field to Outlook appointment

Hello BrotherBook,

I am not completely sure of Attachments in Access.. As I avoid using them.. My general understanding of Attachments in MS Access is that, when you add an attachment, the whole file is uploaded and stored as an Object. This object can be view by using the local applications like MS Word, PDF Reader etc.

That is the reason your Attachment fails.. Simple way to achieve attachments is to have a organised structure (Hyperlinks) to store all files under the Server/Shared Network location, thus allowing the file URL to be used for attachment.. Long way to go around is to Save the attachments to local drives and then use that location for attaching files on Oulook... But I have not worked with this so I am not sure how this code will work for you..

Sorry I could not be of great help..

__________________
Regards,
Paul Eugin

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
!
Windows 7 Professional, MS Access 2010
---------------------------------------------------------------------------------------------------------------------
If the above post has helped you, please click the scales
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
or click the 'Thumbs up'. Cheers.

---------------------------------------------------------------------------------------------------------------------



pr2-eugin is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Outlook Appointment eacollie Modules & VBA 1 06-14-2011 01:05 AM
Adding files to attachment field via query sooner1ksn Modules & VBA 1 12-17-2010 03:53 AM
Update Appointment in Outlook problem Richard M Modules & VBA 0 12-15-2010 12:07 PM
Outlook appointment mnmhemaj General 0 05-23-2008 04:31 AM
How to change an Outlook appointment greaseman Modules & VBA 7 05-14-2007 12:09 PM




All times are GMT -8. The time now is 12:59 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World