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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
PDF generation and Outlook automation error
Hi I have adobe 6 and use the default Adobe PDF printer installed by Adobe. I
have been unsuccessful at trying to automate the print procedure without having to specify a filename/location. Can you help with this at all? After creation I then want to email the PDF to a distribution list using Access 2003 - did you manage to sort out your code with the security errors? Any help would be most appreciated.... Thanks Sue "JoeO" wrote: Thanks sue... I will look at the options I have... Thanks for the help "Sue Mosher [MVP-Outlook]" wrote in message ... 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 http://www.outlookcode.com/jumpstart.aspx "JoeO" wrote in message ... 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 "Sue Mosher [MVP-Outlook]" wrote in message ... 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. "JoeO" wrote in message ... I am using Office2003 (Outlook2003) "Sue Mosher [MVP-Outlook]" wrote in message ... You forgot to mention your Outlook version. If it's Outlook 2002 SP3, see http://www.slipstick.com/outlook/ol2002sp3.htm#problems. Otherwise, see http://www.outlookcode.com/d/sec.htm "JoeO" wrote in message ... 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 |
#2
|
|||
|
|||
PDF generation and Outlook automation error
"hughess7" wrote in message ... Hi I have adobe 6 and use the default Adobe PDF printer installed by Adobe. I have been unsuccessful at trying to automate the print procedure without having to specify a filename/location. Can you help with this at all? After creation I then want to email the PDF to a distribution list using Access 2003 - did you manage to sort out your code with the security errors? Any help would be most appreciated.... Thanks Sue "JoeO" wrote: Thanks sue... I will look at the options I have... Thanks for the help "Sue Mosher [MVP-Outlook]" wrote in message ... 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 http://www.outlookcode.com/jumpstart.aspx "JoeO" wrote in message ... 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 "Sue Mosher [MVP-Outlook]" wrote in message ... 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. "JoeO" wrote in message ... I am using Office2003 (Outlook2003) "Sue Mosher [MVP-Outlook]" wrote in message ... You forgot to mention your Outlook version. If it's Outlook 2002 SP3, see http://www.slipstick.com/outlook/ol2002sp3.htm#problems. Otherwise, see http://www.outlookcode.com/d/sec.htm "JoeO" wrote in message ... 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 |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Does upgrading Schedule+ 7.0 to Outlook 2003 retain the bugs? | EdwinaTSUK | General Discussions | 1 | May 15th, 2005 12:42 AM |
Problem printing 2-sided Outlook Calendars | Charles | Calendar | 3 | August 15th, 2004 04:14 AM |
OAB in automatic profile generation | Christophe Rome | Installation & Setup | 1 | June 17th, 2004 02:38 PM |