Mailing a saved document

D

Duffer

I have got some code to save a document and I want to add more to send the
document to a list of recipients. I have tried the routing slip method but
when the code runs, I get multiple instances of a dialog box which state"A
program is trying to access e-mail addresses you have stored in Outlook. Do
you want to allow this."
At this time I am only sending the document to myself (I want it to work
before I enter the real recipeints), and a copy is sent, but how do I prevent
the dialog box from popping up? Here is what I have

Private Sub Document_Close()
Set myDoc = ActiveDocument
If myDoc = "Living Unit Report.doc" Then
FileL = "H:\union\s86506\S86506_PSSG_CB_AdultCustody_FRCC_Shr\Living
Unit Reports\"
Unit = ActiveDocument.FormFields("DropDown1").Result
Mnth = ActiveDocument.FormFields("DropDown2").Result
Dy = ActiveDocument.FormFields("Text7").Result
Yr = ActiveDocument.FormFields("DropDown3").Result
FileN = FileL & "LUR" & Yr & Mnth & Dy & Unit & ".doc"
Else
GoTo 10
End If

' Can be used if multiple copies of form are saved in same day
' i = 97
' appen = ""
' Do While fs.FileExists(FileN) = True
' appen = Chr(i)
' FileN = FileL & Tag & Yr & Mnth & Dy & Unit & appen & ".doc"
' i = i + 1
' Loop
myDoc.WritePassword = "why"
ActiveDocument.SaveAs FileName:=FileN
ActiveDocument.HasRoutingSlip = True
With ActiveDocument.RoutingSlip
.Subject = "living unit report"
.AddRecipient "(e-mail address removed)"
.Delivery = wdAllAtOnce
End With
ActiveDocument.Route
10
Application.Quit SaveChanges:=wdPromptToSaveChanges
End Sub

Not too clean, but I am just starting to learn VBA.
Thanking you in advance.
 
D

Duffer

Thanks Helmut,
That makes the troublesome dialog box go away, but I don't think it will
solve the problem down the road. When I sent the original post I failed to
mention that I was setting this up for use by others who have little or no
computer knowledge. The process is that they fill out the form and as they
close the form, it saves and e-mails the form to supervisors. There are to be
up to 18 of these forms each day. Is there a simpler way to do this with VBA?
All suggestions are much appreciated.
 
D

Doug Robbins - Word MVP

See the article “How to send an email from Word using VBA†at:

http://word.mvps.org/FAQs/InterDev/SendMail.htm


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
D

Duffer

Thanks Doug,
I saw your previous response to a post and have checked out and used the
link you provided. I incorporated the .Routing code in my code, but ran into
the Dialog box problem. Helmut's suggested link is useful as well, but as I
wrote, the fininshed form will be used by new users who are just learning to
save to folders and not necessarily the right drive let alone folder (which
is why I have the code running on close of document). I will have to get
further direction from my supervisors as to how they want this to work.
Perhaps the easiest solution is to have the supervisors sent the forms once
all are completed.
PS: I don't have administrative privileges on the system we are using so
can't set references other than on my profile...
Thanks again for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top