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.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > Word 2007: getting Run time error -2147467259 (80004005) while saving as a PDF

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-03-09, 08:47
kamorant kamorant is offline
Registered User
 
Join Date: Jun 2009
Posts: 2
Word 2007: getting Run time error -2147467259 (80004005) while saving as a PDF

Hi Gang,

I'm trying to automate the steps of doing a mail merge, update fields and then saving that merge to a number of PDFs. The file names of the PDFs are from the mail merge. The word doc is fairly big as it contains about 25 pages with lots of images.

The VB code goes along and appears to work OK for a time, then I get the following error:

Run-time error '-2147467259 (80004005)

The export failed due to an unexpected error



Here is the code:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub MakePDFs()

Dim FileName As String
Dim FirstRecord As Long
Dim LastRecord As Long
Dim Index As Integer

ActiveDocument.MailMerge.DataSource.ActiveRecord = wdLastRecord
LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord

ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord
FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord

For Index = FirstRecord To LastRecord
Selection.WholeStory
Selection.Fields.Update

Sleep (1000)

FileName = ActiveDocument.MailMerge.DataSource.DataFields.Ite m("PartNumber").Value + ".pdf"

ActiveDocument.ExportAsFixedFormat OutputFileName:= _
ActiveDocument.Path & "\" + FileName _
, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False


Sleep (1000)

ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
Next Index

End Sub


Any help is much appreciated. THANKS!
Reply With Quote
  #2 (permalink)  
Old 06-08-09, 14:35
kamorant kamorant is offline
Registered User
 
Join Date: Jun 2009
Posts: 2
Anyone???

Thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On