Jump to content

Recommended Posts

Posted

:welcome:

Does the printer icon go active?

Maybe increase the sleep time and try a Ctrl+P in there manually, or the file menu method. Maybe something has changed in the syntax of the command.

Never done this with infopath, or used that script.

It might be possible to alter the vb version to open infopath instead of Word.

Posted

Thanks for the suggestions.

 

No, the printer icon does not go active. No evidence of printing.

 

What would be the Powershell script for getting into the file menu of Infopath and essentially instructing it to File, Print?

 

There are definitely some differences between Infopath and other Microsoft files. The start-process command (with a file path and filename) works fine to open and print a Word document, but returns errors when the exact same code is used and an xml file is substituted.

  • 1 year later...
Posted

Ok, over a year later and your script finally worked. There may be more than one variable, but I think it was just a simple syntax problem:

 

I was using "Printout()" ..... when I changed it to "PrintOut()" in both locations in the script, it started working............. Thanks!

  • 4 weeks later...
Posted

Even changing to PrintOut didn't work for me in Infopath Filler / Designer 2013 running forms saved in O365.

I have played and finding that this is working, to use AppActivate and SendKeys:

# $infopath.XDocuments[0].PrintOut() sleep(3)

$wshell = New-Object -ComObject wscript.shell;

$wshell.AppActivate("$shortname - InfoPath");

$wshell.SendKeys("%FPQ");

sleep(1)

$wshell.SendKeys("~");

sleep(3)

 

Hope this helps others :)

  • 3 months later...
Posted

Hey, man. Just wanted to thank you. This worked and life has now become bearable. I know your post is four years old, but I still had to reply. Just a heads up that there is a space in this line ($verbose){$verbosepreference="continue";$erroractionpreference="continue"} that you have to fix to make it work (shows up as '$errora ctionpreference' in the original post). I'm pretty sure SoftwareAdmin pasted the right code, but the forum retroactively added a space--maybe as some kind of security measure--but who knows? I suck at this stuff! :D

 

 

Just wanted to put this on as I ran into this situation trying to convert the Infopath xml docs into a PDF writer.

 

I tried the right click print registry hack and modified it to open Infopath instead of Word. This ultimately failed due to the lack of switches I could find that would allow Infopath to open print close.

 

I tried the Bulk print vbs script on here. This did what it was supposed to but Word only pulls the XML raw code not the Infopath forms so it was not what i needed.

 

 

Finally I stumbled on a Powershell scritpt that works Perfectly. Credit here bsonposh .com /archives /468 /BSonPoSH

 

 

Printing Multiple InfoPath forms

 

 

Install details for novice users

Copy the Text between the dashed lines into Notepad. Then change the line containing "\\sharepoint.corp.com\Form_Folder" to the location of the folder needing converted for example "c:\sharepoint\Forms"

Close and Save the notepad. Now rename the .txt extention to ps1. Double Click and your off and running. FYI should you need to edit the PS1 file, Right Click Edit. The script will automatically launch the Powershell interface which you can edit in as well.

 

 

* Note if you are converting to PDF you will need a PDF writer set as the default printer. Your pdf printer should be configured to print out using the same name as the current name in Infopath so everything is kept orderly. Test on a small folder before trying a big converson.

 

---------------------------------------------------------------------------------------

 

Param($Path = "\\sharepoint.corp.com\Form_Folder",[switch]$verbose)

 

Write-Host

 

function Invoke-FormPrint

{

Param($InfoForm)

$shortname = $InfoForm.name

Write-Verbose " – FormPrint: Creating COM Object"

$infopath = New-Object -com InfoPath.Application -verbose:$false

Write-Verbose " – FormPrint: Calling Open(`$InfoForm.fullname,10)"

$infopath.XDocuments.Open($InfoForm.fullname,10) | out-null

Write-verbose " – FormPrint: Calling PrintOut()"

$infopath.XDocuments[0].printout()

sleep 10

Write-verbose " – FormPrint: Calling Quit()"

$infopath.quit()

if(!$?)

{

Write-Host " - Error printing Form: $shortname" -fore RED

}

else

{

Write-Host " - Successfully printed Form: $shortname" -fore Green

}

}

 

$erroractionpreference = "silentlycontinue"

 

if($verbose){$verbosepreference="continue";$erroractionpreference="continue"}

 

Write-Verbose " + Processing all Forms from: $path"

$Forms = dir $path "*.xml"

 

Write-Verbose " + $($Forms.count) Forms found"

Write-host " + Processing all $($Forms.count) Forms located at: $path" -fore White

 

foreach($Form in $Forms)

{

Write-Host " + Printing Form: $($Form.Name)" -fore White

Invoke-FormPrint $Form

}

 

 

-----------------------------------------------------------------------------------------------------------

 

 

Windows 7 with Office 2010

  • Thanks 1
  • 3 years later...
Posted
Sorry to reopen a super old thread but did this ever exist for excel XML files? SIMS still being an XML pain! Thanks

 

I’m not sure if the version here still works. It might require tweaking to keep up with changes in Office.

There was no Excel version as it was designed for Ind Reports.

Can’t check now but I think there was a line that would call Word to open or it’s declared early on as an object.

Changing that to the Excel equivalent would do the trick assuming other parameters are the same.

 

I don’t suppose a bulk rename to .xls or .xlsx allows you to use right click print?

There might be other solutions available now.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...