A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Coding Multiple Variable Attachments for Appointments in VBA



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 21st 08, 04:41 PM posted to microsoft.public.outlook.program_vba
Joe Jacobs
external usenet poster
 
Posts: 1
Default Coding Multiple Variable Attachments for Appointments in VBA

Hello! I am attempting to code a routine that originates Outlook
appointments from within an Access 2K database. Although I have no problem
coding for the basic appointment parameters, I am having trouble with the
attachments.

BACKGROUND -- I have built a project management database that contains a
group of forms dedicated to training. Within this group, the user can
designate attendees, resources, and documents that will be used to schedule
subsequent training sessions. Paths to the documents are stored in
tblProcessDocs. Only those docs linked to the primary key of the training
record are available for attachment to the appointment.

When I attempt to attach the documents, however, I receive the following
error: "File name or directory name is not valid." (NOTE: Error number
changes depending upon the file selected, but the description remains
consistent.)

HOW IT WORKS: In the routine (code below), I set the basic parameters for
the appointment, assign recipients, and assign resources. Then I create a
snapshot recordset and determine if the main training record contains any
process document subrecords. If true, then I run an attachment loop. Within
this loop, I open an attachment form as a dialog that displays all the
documents available for the training sessions. On clicking a command button,
the doc path is placed in a public variable that is then used in the
..Attachments.Add(DocPath) method. This loop then repeats until the user
closes the attachment dialog, which sets a additional public variable to
True. In short, the user can add any number of attachments, any one of which
may be different depending upon the training session to which it is linked.

CODE:
Module Code

Public myDocLink As String
Public myAttachedFlag As Boolean

Attachment Form Code

Private Sub cmdAttachApptDoc_Click()
myDocLink = Me.DocPath.Value
DoCmd.Close
End Sub

Private Sub cmdCloseApptAttachForm_Click()
myAttachedFlag = True
DoCmd.Close
End Sub

Schedule Appointment Code (different form)

Dim myPath as String
...

Set myAttendeeBase = CurrentDb
Set myAttendeeSet = myAttendeeBase.OpenRecordset("SELECT
tblProcessDocs.DocPath FROM tblProcessDocs WHERE
(((tblProcessDocs.TrainingID)= " & myAttendeeID & "));", dbOpenSnapshot)

If myAttendeeSet.RecordCount 0 Then
Do While myAttachedFlag = False
DoCmd.OpenForm "frmProcessDocsTrainingAttachments", , , , ,
acDialog
myPath = """" & myDocLink & """"
Debug.Print myPath
Set myApptAttachments = objAppt.Attachments.Add(myPath)
Loop
End If
CODE END


The Immediate window shows the following string for myPath:
"C:\Documents and Settings\z035238\My Documents\Data Sources in InfoPath.pdf"

Given this, I do not understand why I am receiving the error noted above.
Although I am new to VBA, I have scoured the newsgroups here at MSDN and
other sites to find an answer on my own. Having failed, I'm reaching out for
more explicit help. Thanks in advance!!!


Ads
  #2  
Old July 21st 08, 09:06 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Coding Multiple Variable Attachments for Appointments in VBA



Adding myDocLink should be fine, probably in myPath there're too many "".

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Mon, 21 Jul 2008 08:41:01 -0700 schrieb Joe Jacobs:

Hello! I am attempting to code a routine that originates Outlook
appointments from within an Access 2K database. Although I have no

problem
coding for the basic appointment parameters, I am having trouble with the
attachments.

BACKGROUND -- I have built a project management database that contains a
group of forms dedicated to training. Within this group, the user can
designate attendees, resources, and documents that will be used to

schedule
subsequent training sessions. Paths to the documents are stored in
tblProcessDocs. Only those docs linked to the primary key of the training
record are available for attachment to the appointment.

When I attempt to attach the documents, however, I receive the following
error: "File name or directory name is not valid." (NOTE: Error number
changes depending upon the file selected, but the description remains
consistent.)

HOW IT WORKS: In the routine (code below), I set the basic parameters for
the appointment, assign recipients, and assign resources. Then I create a
snapshot recordset and determine if the main training record contains any
process document subrecords. If true, then I run an attachment loop.

Within
this loop, I open an attachment form as a dialog that displays all the
documents available for the training sessions. On clicking a command

button,
the doc path is placed in a public variable that is then used in the
.Attachments.Add(DocPath) method. This loop then repeats until the user
closes the attachment dialog, which sets a additional public variable to
True. In short, the user can add any number of attachments, any one of

which
may be different depending upon the training session to which it is

linked.

CODE:
Module Code

Public myDocLink As String
Public myAttachedFlag As Boolean

Attachment Form Code

Private Sub cmdAttachApptDoc_Click()
myDocLink = Me.DocPath.Value
DoCmd.Close
End Sub

Private Sub cmdCloseApptAttachForm_Click()
myAttachedFlag = True
DoCmd.Close
End Sub

Schedule Appointment Code (different form)

Dim myPath as String
...

Set myAttendeeBase = CurrentDb
Set myAttendeeSet = myAttendeeBase.OpenRecordset("SELECT
tblProcessDocs.DocPath FROM tblProcessDocs WHERE
(((tblProcessDocs.TrainingID)= " & myAttendeeID & "));", dbOpenSnapshot)

If myAttendeeSet.RecordCount 0 Then
Do While myAttachedFlag = False
DoCmd.OpenForm "frmProcessDocsTrainingAttachments", , , , ,
acDialog
myPath = """" & myDocLink & """"
Debug.Print myPath
Set myApptAttachments = objAppt.Attachments.Add(myPath)
Loop
End If
CODE END


The Immediate window shows the following string for myPath:
"C:\Documents and Settings\z035238\My Documents\Data Sources in

InfoPath.pdf"

Given this, I do not understand why I am receiving the error noted above.
Although I am new to VBA, I have scoured the newsgroups here at MSDN and
other sites to find an answer on my own. Having failed, I'm reaching out

for
more explicit help. Thanks in advance!!!

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
colour-coding appointments S Sharp Outlook - Calandaring 2 July 28th 07 03:09 AM
Any free programs that help set variable recurring appointments Seawolf Outlook - Calandaring 3 April 11th 07 02:40 PM
Multiple Attachments Terry Bennett Outlook - General Queries 4 February 4th 07 07:56 PM
Outlook 2000 color coding appointments in calendar texas Outlook - Calandaring 1 August 20th 06 06:34 PM
Color coding different users appointments in Outlook 2000 Calande. Docmike Outlook - Calandaring 2 March 31st 06 03:01 PM


All times are GMT +1. The time now is 03:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.