Runtime error -2147467259 during PDF generation -


i'm newbie in using vbscript , don't understand why errorcode -2147467259 ("-2147467259: file in use application or user")(this own translation because error message in german). trying generate pdf files serial letter in ms word 2007 via vbscript. there on 28.000 pdf files generate .docx-file. maybe great number reason script fails don't hope ;).

here vb code using:

sub pdferstellung()     dim sbrief string     dim svertreterverzeichnis string     dim sausgabepfad string     dim ianzahl integer     dim skundenname string     dim serror string     dim imodulo integer      application.visible = false     sausgabepfad = "c:\temp\"      on error goto fehler      activedocument.mailmerge         .datasource.activerecord = wdlastrecord         ianzahl = .datasource.activerecord         .datasource.activerecord = wdfirstrecord                     .destination = wdsendtonewdocument             .suppressblanklines = true             .datasource                 .firstrecord = .activerecord                 .lastrecord = .activerecord                 svertreterverzeichnis = sausgabepfad & .datafields("vertreternr").value                 if not isdiskfolder(svertreterverzeichnis)                     mkdir svertreterverzeichnis                 end if                 skundenname = cleanfilename(left(.datafields("kundenname").value, 20), "")                 sbrief = svertreterverzeichnis & "\" & .datafields("vertreternr").value & "_" & _                             .datafields("kundennr").value & "_" & skundenname & ".pdf"             end             .execute pause:=false             activedocument.exportasfixedformat outputfilename:=sbrief _                 , 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                          if instr(1, activewindow.caption, "serien") = 1                 activewindow.close false             end if              if .datasource.activerecord < ianzahl                 .datasource.activerecord = wdnextrecord             else                 exit             end if         loop     end     application.quit savechanges:=wddonotsavechanges      end sub 

the thing can' understand script aborts @ different times different numbers of created pdf files. stopps after ~800 files, after ~7.000 , on. not felt had worked once! mind, trying generate 28.000 files.

additionally have word using .csv-file (7 mb) exported database.

is there can do?

i have noticed if close 'activewindow' i'm able create far more pdf file without closing windows. without closing, there limited number of generated pdf files (i have test again because can't remember number - 2.000?!).

at last attempt implemented sleep method executed after 'activewindow.close false'. @ first time seemed after 3 times there little improvement determine...

have idea?

(i hope english not bad 1 can not understand it...)

i split task into:

  1. generate 27.000 .doc(x) letters (fallback: in batches of 1.000; if word can't that, you'll have valid claim against mr. gates)
  2. convert 27.000 .doc(x) letters .pdf (fallback: use specialized tool instead of word)

the code sub task can derived existing loop (making less complex); additional condition - don't process if target file exists - shouldn't hard. if work in batches, have @ least part done after each step.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -