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.
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.