PDA

View Full Version : email acropdf as attachment



m_court15
10-21-2011, 08:07 AM
I have a userform that pops up with an open dialog box, then you select the pdf you want to view. The pdf is then shown in an acropdf. I am trying to get the pdf that is shown with the acro pdf to be e-mailed as an attachment. Any Ideas?

Here is what I have. I have no idea if I am close with the email part.
Option Explicit
Private oVars As Variables

Private Sub cmdBack_Click()
'GOES BACK TO MAIN MENU
Unload Me
MainMenu.Show
End Sub

Private Sub cmdClose_Click()
Unload Me
ActiveDocument.Close savechanges:=False
End Sub

Private Sub cmdEmail_Click()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = "mcourtright@hfgp.com"
.subject = "New subject"
'Add the document as an attachment, you can use the .displayname property
'to set the description that's used in the message
.Attachments.Add ActiveDocument.AcroPDF
.Send
End With
If bStarted Then
oOutlookApp.Quit
End If
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub

Private Sub UserForm_Initialize()
Application.Visible = False
ChangeFileOpenDirectory "\\hfgpmain\engineering\hardware\test (file://\\hfgpmain\engineering\hardware\test) userform\view only\"
Options.DefaultFilePath(wdDocumentsPath) = CurDir
With Dialogs(wdDialogFileOpen)
.name = "*.pdf"
If .Display = -1 Then
AcroPDF1.LoadFile WordBasic.FileNameInfo(.name, 1)
End If
End With
Application.Visible = False
End Sub

m_court15
10-26-2011, 05:08 AM
Does anyone have any ideas? I cannot find anything.