question

SunnyWong-3293 avatar image
0 Votes"
SunnyWong-3293 asked RichMatheisen-8856 commented

Powershell or VBS to print file already opened by Internet Explorer

Visio file (vsd extension), unfortunately, to print needs File Open as prerequisite.; can't be printed by Windows 10 File Explorer Right-Click-Print.

File Open to print becomes tedious with numerous such files.
I have script to drop file into PS script to open file with IE; but have not figure out script to

  1. save file (timestamping original name ) already opened by IE

  2. setup page layout

  3. prompt user to send to printer

  4. print


This is Windows 10 Enterprise.









windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

Visio has command line switches and parameters. Have you tried using them?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LimitlessTechnology-2700 avatar image
0 Votes"
LimitlessTechnology-2700 answered SunnyWong-3293 commented

Hi there,

The Invoke-Item cmdlet performs the default action on the specified item. For example, it runs an executable file or opens a document file in the application associated with the document file type.

This command opens all of the Microsoft Office Excel spreadsheets in the C:\Documents and Settings\Lister\My Documents folder. Each spreadsheet is opened in a new instance of Excel. In this case, opening in Excel is the default action for .xls files.

Invoke-Item "C:\Documents and Settings\Lister\My Documents*.xls"

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/invoke-item?view=powershell-7.1



--If the reply is helpful, please Upvote and Accept it as an answer--

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

TQ but i already have script to open with another method.

 & "C:\Program Files\Internet Explorer\iexplore.exe" "Z:\abc.vsd"

How to send Print Command to IE?


0 Votes 0 ·
SunnyWong-3293 avatar image
0 Votes"
SunnyWong-3293 answered RichMatheisen-8856 commented

My job not expected to need Visio; waiting for approval to get Visio.

With no app to try, i can only find
[command-line-switches-for-microsoft-visio-2010-f1de9af3-8368-4ef0-9a2f-25d430ec5576][1].
which didn't mention anything for printing.

I have yet found "Command-line switches for Microsoft Visio 365"

If you know where, I appreciate info.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I believe there are "/p" and "/pt" switches and parameters on the Visio command line.

0 Votes 0 ·
RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered RichMatheisen-8856 commented

You would probably have more success using an IE COM object.

To print to your default printer, use something like this "$IE.ExecWB(6,2)"

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

you are correct. I have not been able to Sendkey to IE11. Here's code to implement your suggestion
remove-variable InternetExplorer
$url = "Z:\Flowchart_2015.vsd"
$script:InternetExplorer = New-Object -com "InternetExplorer.Application"
$script:InternetExplorer.visible = $true
$InternetExplorer.Navigate($Url)
$InternetExplorer.ExecWB(6,2)

For Page Layout, IE have PageSetup, is there script to access ?
Thanks Ahead!

0 Votes 0 ·

The description of the ExecWB COM method is here: aa752087(v=vs.85)

You'll find the OLECMDID enumeration values here: ne-docobj-olecmdid. You already know that the value "6" is OLECMDID_PRINT, so a "9" should be OLECMDID_PAGESETUP.

The OLECMDEXECOPT enumeration enumeration values are here: ne-docobj-olecmdexecopt. You're already using the value "3" (OLECMDEXECOPT_DONTPROMPTUSER), so if you want to have the user fill in the values, use a value of "2" (OLECMDEXECOPT_PROMPTUSER)


0 Votes 0 ·