PowerShell Word Mail Merge Script -
i have script used work fine on older versions of office on 2010 failing mail merge documents correctly.
the interesting thing if load mail merge document (by double clicking) tells me mail merge document , needs confirm source data file. fine behaviour not same if open via ps loads normal document, troublesome snippet of code below:
if ($choice) { $word = new-object -com "word.application" $template=$word.documents.open("$template_path\$choice",$word.wdreadonly) $word.activedocument.mailmerge.execute() $template.close([ref]$word.wddonotsavechanges) $word.visible = 'true' }
i did come across link exampled problem i'm not expert coder , information went on head little bit, stated this:
sub openword(filename) set word = wscript.createobject("word.application") word.visible = true set doc = word.documents.open(filename) end sub have seen issues such code if word document has mail merge data source associated , try execute (see word mail merge). doc.mailmerge.execute true trying execute mail merge generates ‘this method or property not available because document not mail merge main document.’ know wrong because double clicking on file reveals data source associated document. way open word document , circumvent issue use run command such as: sub openword(filename) set wshshell = wscript.createobject("wscript.shell") wshshell.run filename, 8, false end sub
could explain how can take information , apply powershell script?
ensure windows registry setting "sqlsecuritycheck" described in support.microsoft.com/kb/825765 have been set word 2010 older versions of word.
Comments
Post a Comment