Jump to content

Recommended Posts

First let me start by saying thank you to everyone on these forums as I would not have been able to make it this far without your help. My script heavily borrows from scripts already posted on here. My script stores a file name and a printer name in a 2d array from an excel sheet. It then iterates through the array sending each file to its corresponding printer using DDE printing.

Here's my code:

#include <Excel.au3>

#include <Array.au3>

#include <DDEML.au3>

#include <DDEMLClient.au3>

;Open excel sheet and store printer names + file names in array

$fVisible = 0

$sFilePath = "C:\Documents and Settings\afowler2\Desktop\Final_flowsheet_SI_2.xls"

Local $oExcel = _ExcelBookOpen($sFilePath , $fVisible, True)

If @error = 1 Then

MsgBox(0, "Error!", "Unable to Create the Excel Object")


ElseIf @error = 2 Then

MsgBox(0, "Error!", "File does not exit!")



$iStartRow = 1

$ColCnt = 2

Local $aArray = _ExcelReadSheetToArray($oExcel, $iStartRow,1,0,$ColCnt)

;Iterate through the array and send off flowsheets

Local $filename = ""

Local $printer = ""

For $r = 1 To UBound($aArray,1) -1

$filename = "C:\flowsheets\" & "V6 - " & $aArray[$r][1]&".pdf"

;MsgBox(0,"my files",$filename)

$printer = $aArray[$r][2]

;Print using DDE

ShellExecute("AcroRD32.exe", "/h")

Opt("WinTitleMatchMode", 2)



$szService = "acroviewR10"

$szTopic = "Control"

$szCommand = '[FilePrintTo("'&$filename&'","'&$printer&'")][AppExit()]'

_DDEMLCLient_Execute($szService, $szTopic, $szCommand)




The problem is sometimes Adobe hangs up while opening a file and I have to close it by click "end now" before the script will continue on. Also I would prefer to use the DDE command "FilePrintSilent" but I do not know of a way to specify a printer with this command. I would like to create an error log as well to show which prints went through and which didn't.

Any help is much appreciated.

Link to post
Share on other sites

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...