PDF generation and Outlook automation error

J

JoeO

I have posted this problem to VB newsgroup but was advised to try Access and
Outlook newsgroups...


My VB6 App opens an Access Report and generates report in PDF, and then
open/load outlook and place the generated report as attachment to outlook
once the report is closed. This is accomplished by:

Switching over to the Acrobat Printer (i.e. PDFWriter) from the default
printer.

Setting a string type sub key "PDFFilename" in the registry
"HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter" to store the PDF in a
user selected directory with a filename that's determined by VB codes.

Generating the PDF by issuing the command ".DoCmd.OpenReport sReport,
acViewNormal".

Closing the report by issuing the command ".DoCmd.Close acReport,
ReportName, acSaveNo".

Resetting to the default printer from Acrobat Printer "PDFWriter".

This app has worked for ages without problems. But my client recently
upgraded his system and installed a new version of Acrobat. In fact he now
uses Acrobat Distiller. Problem is the existing code no longer works. Access
generates "Report that can not be printed" error and then goes ahead to
generate unreadable txt file

Even Outlook shows "Another program is trying to access outlook address....
this might be a virus" alert. I don't want the alert to show when my app
opens Outlook. What can I do to fix these problems. Please help
 
S

Sue Mosher [MVP-Outlook]

Did you look at the page I suggested? If you post the portion of the code that involves Outlook, we can tell you for sure what part of it is triggering the security prompt.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

JoeO

Thanks Sue. Here is the code. Worked for years with Outlook2000

Sub SendEmail(sEmail As String, sWO As String, sPO As String, _
DisplayMsg As Boolean, Optional AttachmentPath)
On Error Resume Next
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
'Create Outlook Application
Set objOutlook = CreateObject("Outlook.Application")
'Create Message
Set objOutlookMsg = Outlook.CreateItem(olMailItem)

With objOutlookMsg
'Add Recipient(s) To the Message
Set objOutlookRecip = .Recipients.Add(sEmail)
objOutlookRecip.Type = olTo
'Add the cc recipients
''Set objOutlookRecip = .Recipients.Add("Michael")
'Set Subject and Impportance
.Subject = "Job Report.. WO: " & sWO & " PO: " & sPO

'Add Attachments
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
'Add Job Photos if they exist in database
If frmJobReport.chkPhoto.Value = 1 Then
Dim rs As Recordset, sSQL As String, sFile As String
sSQL = "Select WorkOrderNum, Title, Note from tbl_JobPhoto Where
WorkOrderNum = '" & sWO & "'"
Set rs = db.OpenRecordset(sSQL, dbOpenSnapshot)
'Indicate Photos attached
.Body = .Body & vbCrLf & "Photo(s) attached... "
Do Until rs.EOF
sFile = modGeneral.sJobPic & rs!Title
Set objOutlookAttach = .Attachments.Add(sFile) & vbCrLf
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End If
'Set Body
.Body = "Job report for Work Order " & sWO & vbCrLf & "Client PO #: "
& sPO & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High Importance
.Body = .Body & vbCrLf & "Sincerely"
.Body = .Body & vbCrLf & UserName & vbCrLf & Format(Now, "dddd
mmm/dd/yyyy h:mm ampm")
'Resolve Each Recipients Name
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
'Should we display
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlookRecip = Nothing
Set objOutlookMsg = Nothing
objOutlook.Close
Set objOutlook = Nothing


Basically what the code does is open Outlook, attach a PDF file and photos
if they exist in database... Then it adds a few lines of comments describing
some job information. Receipient email address is added if the
(receipient's) email address exists in the form that calls outlook
automation... otherwise the code does not access outlook's address book. I
don't know what outlook security setting this code could be flouting. Please
help

Did you look at the page I suggested? If you post the portion of the code
that involves Outlook, we can tell you for sure what part of it is
triggering the security prompt.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Your code is using many properties and methods that have been restricted by Outlook security since Outlook 2000 SP2. See http://www.outlookcode.com/d/sec.htm for your options.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

JoeO

Thanks sue... I will look at the options I have... Thanks for the help

Your code is using many properties and methods that have been restricted by
Outlook security since Outlook 2000 SP2. See
http://www.outlookcode.com/d/sec.htm for your options.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

candy

JoeO said:
I have posted this problem to VB newsgroup but was advised to try Access and
Outlook newsgroups...


My VB6 App opens an Access Report and generates report in PDF, and then
open/load outlook and place the generated report as attachment to outlook
once the report is closed. This is accomplished by:

Switching over to the Acrobat Printer (i.e. PDFWriter) from the default
printer.

Setting a string type sub key "PDFFilename" in the registry
"HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter" to store the PDF in a
user selected directory with a filename that's determined by VB codes.

Generating the PDF by issuing the command ".DoCmd.OpenReport sReport,
acViewNormal".

Closing the report by issuing the command ".DoCmd.Close acReport,
ReportName, acSaveNo".

Resetting to the default printer from Acrobat Printer "PDFWriter".

This app has worked for ages without problems. But my client recently
upgraded his system and installed a new version of Acrobat. In fact he now
uses Acrobat Distiller. Problem is the existing code no longer works. Access
generates "Report that can not be printed" error and then goes ahead to
generate unreadable txt file

Even Outlook shows "Another program is trying to access outlook address....
this might be a virus" alert. I don't want the alert to show when my app
opens Outlook. What can I do to fix these problems. Please help
 
U

uriel

JoeO said:
I have posted this problem to VB newsgroup but was advised to try Access
and
Outlook newsgroups...


My VB6 App opens an Access Report and generates report in PDF, and then
open/load outlook and place the generated report as attachment to outlook
once the report is closed. This is accomplished by:

Switching over to the Acrobat Printer (i.e. PDFWriter) from the default
printer.

Setting a string type sub key "PDFFilename" in the registry
"HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter" to store the PDF in a
user selected directory with a filename that's determined by VB codes.

Generating the PDF by issuing the command ".DoCmd.OpenReport sReport,
acViewNormal".

Closing the report by issuing the command ".DoCmd.Close acReport,
ReportName, acSaveNo".

Resetting to the default printer from Acrobat Printer "PDFWriter".

This app has worked for ages without problems. But my client recently
upgraded his system and installed a new version of Acrobat. In fact he now
uses Acrobat Distiller. Problem is the existing code no longer works.
Access
generates "Report that can not be printed" error and then goes ahead to
generate unreadable txt file

Even Outlook shows "Another program is trying to access outlook
address....
this might be a virus" alert. I don't want the alert to show when my app
opens Outlook. What can I do to fix these problems. Please help
 
S

Steve Rindsberg

It's a good idea to keep an eye on the Acrobat support forums at www.adobe.com
if your application depends on Acrobat. Adobe began discouraging the use of
PDFWriter in Acrobat 5 (where it was only available to users via a custom
install) and dropped support for it completely in Acrobat 6. We're now at
Acrobat 7.

If you don't mind having the users asked for a filename for the PDF when they
print, you can probably just select the Distiller or Adobe PDF printer
programmatically (which you pick depends on the version of Acrobat they have).
 
Y

yuanyuan

Steve Rindsberg said:
It's a good idea to keep an eye on the Acrobat support forums at www.adobe.com
if your application depends on Acrobat. Adobe began discouraging the use of
PDFWriter in Acrobat 5 (where it was only available to users via a custom
install) and dropped support for it completely in Acrobat 6. We're now at
Acrobat 7.

If you don't mind having the users asked for a filename for the PDF when they
print, you can probably just select the Distiller or Adobe PDF printer
programmatically (which you pick depends on the version of Acrobat they have).



--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
M

MAOFANSHUN66666

KLKLKL
Steve Rindsberg said:
It's a good idea to keep an eye on the Acrobat support forums at
www.adobe.com
if your application depends on Acrobat. Adobe began discouraging the use
of
PDFWriter in Acrobat 5 (where it was only available to users via a custom
install) and dropped support for it completely in Acrobat 6. We're now at
Acrobat 7.

If you don't mind having the users asked for a filename for the PDF when
they
print, you can probably just select the Distiller or Adobe PDF printer
programmatically (which you pick depends on the version of Acrobat they
have).



--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 

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