Jump to content

_wordDocPrint only prints to default printer


Recommended Posts

Hi Guys,

I'm running Windows 7 64 bit and Office 2010 64bit. I am trying to print a word document and nothing comes out when I try to specify the printer by name. I have tried a shared network name and a local printer name and niether work. If I don't specify a printer and send it to the default printer it prints OK. I have compiled both 32 and 64bit exe's and they both do the same thing.

I have made a cut down example to demonstraight the problem. I started with the example script so I should be very close.

;Test Print
;http://www.autoitscript.com/autoit3/docs/libfunctions/_WordDocPrint.htm
#include <word.au3>
Local $hWordApplication
Local $hWordDocument
Local $BackgroundPrint=0
Local $Copies=1
Local $Orientation=-1  ;(Current Default)
Local $Collate=1
Local $Range=0    ;Entire document
Local $PageFrom=0    ;Starting page when Range=3
Local $PageTo=0   ;Ending page when Range=3
Local $Pages=0   ;The page numbers to be printed seperated by commas when Range=4
Local $PageType=0    ;0=All, 1=Odd and 2=Even
Local $Item=0
;Local $printerName="\\vjraywks05\HPOfficejet6500"
Local $printerName="HPOfficeJet6500"

$hWordApplication = _WordCreate(@ScriptDir & "\Test.doc")
$hWordDocument = _WordDocGetCollection($hWordApplication, 0)
$hWordDocument.Range.Text = "This is some text to print."
;_WordDocPrint($hwordDocument) ;<--- This prints to the default printer
_WordDocPrint($hWordDocument, $BackgroundPrint, $Copies, $Orientation, $Collate, $PrinterName, $Range, $PageFrom, $PageTo, $Pages, $PageType, $Item)
MsgBox(0,"Debug","Print Document=" &@error & @extended)
_WordQuit($hWordApplication, 0)

My Message box after the _WordDocPrint() command returns 00.

Any Ideas where I'm going wrong.

David

PS I did post this question a month or two ago. I thought I solved it but the default printer was just tricking me. :(

Link to comment
Share on other sites

I encounter the same problem here: Windows 7 SP1 64 bit, office 2010 32 bit.

As I'm about to rewrite the Word UDF I will investigate the problem ...

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I tested _WordDocPrint on Windows XP and it works just fine.

Maybe it's a permission problem with W7?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I did some more testing on Windows 7 and noticed that "servernamePrintername" seems to be case sensitive.

I added a printer to Windows 7, it shows up as "DRPDF_File" on "Spool3". _WordDocPrint works only if use "Spool3DRPDF_File". All other lowercase/uppercase notations fail.

Could you test if this is true for your environment too?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hi Water,

Sorry for the slow reply. For some reason even though am "Following" this thread I'm not getting email notifications of any new posts.

Anyway, I have checked the spelling of my printer name and the case was spot on. My workstation name seems to be all in upper case.

I have tried a couple of different combinations but it stil doesn't print anything and the @error and @extended are still 00.

I'm at a bit of a loss for what else to try?

David

Link to comment
Share on other sites

Could you please run this test script? Change the parameters of _WordDocPrintEX to your needs.

#include <word.au3>

Global $oWordApp = _WordCreate("")
Global $oDoc = _WordDocOpen($oWordApp, @ScriptDir & "Test.doc")
$oWordErrorHandler = ObjEvent("AutoIt.Error", "MyErrFunc")
_WordDocPrint($oDoc, 0, 1, -1, 1, "spool3xyz")
ConsoleWrite(@error & "-" & @extended & @CRLF)
_WordQuit($oWordApp)
Exit

Func MyErrFunc()
; Important: the error object variable MUST be named $oWordErrorHandler
Local $ErrorScriptline = $oWordErrorHandler.scriptline
Local $ErrorNumber = $oWordErrorHandler.number
Local $ErrorNumberHex = Hex($oWordErrorHandler.number, 8)
Local $ErrorDescription = StringStripWS($oWordErrorHandler.description, 2)
Local $ErrorWinDescription = StringStripWS($oWordErrorHandler.WinDescription, 2)
Local $ErrorSource = $oWordErrorHandler.Source
Local $ErrorHelpFile = $oWordErrorHandler.HelpFile
Local $ErrorHelpContext = $oWordErrorHandler.HelpContext
Local $ErrorLastDllError = $oWordErrorHandler.LastDllError
Local $ErrorOutput = ""
$ErrorOutput &= "--> COM Error Encountered in " & @ScriptName & @CR
$ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & @CR
$ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex & @CR
$ErrorOutput &= "----> $ErrorNumber = " & $ErrorNumber & @CR
$ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription & @CR
$ErrorOutput &= "----> $ErrorDescription = " & $ErrorDescription & @CR
$ErrorOutput &= "----> $ErrorSource = " & $ErrorSource & @CR
$ErrorOutput &= "----> $ErrorHelpFile = " & $ErrorHelpFile & @CR
$ErrorOutput &= "----> $ErrorHelpContext = " & $ErrorHelpContext & @CR
$ErrorOutput &= "----> $ErrorLastDllError = " & $ErrorLastDllError
MsgBox(0, "COM Error", $ErrorOutput)
SetError(1)
Return
EndFunc ;==>MyErrFunc

Func _WordDocPrintEX(ByRef $o_object, $f_Background = 0, $i_Copies = 1, $i_Orientation = -1, $f_Collate = 1, $s_Printer = "", $i_Range = 0, $i_From = "", $i_To = "", $s_Pages = "", $i_PageType = 0, $i_Item = 0)

Local $s_ActivePrinter, $i_Extended, $i_DocOrientation = "", $i_ErrorStatusCode = $_WordStatus_Success, $s_ErrorMSG = ""

Switch $i_Range
Case 3
If Not $i_From Or Not $i_To Then
Return SetError($_WordStatus_InvalidValue, 7, 0)
EndIf
Case 4
If Not $s_Pages Then
Return SetError($_WordStatus_InvalidValue, 7, 0)
EndIf
EndSwitch

$i_Orientation = String($i_Orientation)
If $i_Orientation <> "-1" Then
Switch $i_Orientation
Case "0", "1"
$i_DocOrientation = String($o_object.PageSetup.Orientation)
If $i_DocOrientation <> $i_Orientation Then
$o_object.PageSetup.Orientation = $i_Orientation
EndIf
Case Else
Return SetError($_WordStatus_InvalidValue, 4, 0)
EndSwitch
EndIf

If $s_Printer Then
$s_ActivePrinter = $o_object.Application.ActivePrinter
$o_object.Application.ActivePrinter = $s_Printer
ConsoleWrite(@error & @CRLF)
If @error = $_WordStatus_ComError And $WordComErrorNumber = -2147352567 And $WordComErrorDescription = "There is a printer error." Then
$i_ErrorStatusCode = $_WordStatus_InvalidValue
$s_ErrorMSG = "Invalid printer name specified."
$i_Extended = 6
EndIf
EndIf

$i_From = String($i_From)
$i_To = String($i_To)
If Not $i_ErrorStatusCode Then
; $o_object.PrintOut($f_Background, 0, $i_Range, "", $i_From, $i_To, $i_Item, $i_Copies, $s_Pages, $i_PageType, 0, $f_Collate)
If @error = $_WordStatus_ComError Then
$i_ErrorStatusCode = $_WordStatus_ComError
EndIf
EndIf

If $i_DocOrientation <> "" And $i_DocOrientation <> $i_Orientation Then
$o_object.PageSetup.Orientation = $i_DocOrientation
EndIf
If $s_ActivePrinter Then
$o_object.Application.ActivePrinter = $s_ActivePrinter
EndIf

EndFunc ;==>_WordDocPrint
A MsgBox with extended error information should pop up.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 1 month later...

I was receiving @Extended 3, with the above function @Error and @Extended are both 0. My default printer is set as CutePDF, as I do not currently have a printer hooked up to my main box. Is this function now working with a physical printer?

Thanks!

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

I have rewritten the Word UDF, you can download it

You need at least AutoIt 3.3.9.2 beta to run the UDF. Could you give it a try?

What could cause your problem is that you run the 64 bit version of Office. Even Microsoft recommends to use the 32 bit version.

Do you have a computer with Office 2010 32 bit available where you can test?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I have rewritten the Word UDF, you can download it

You need at least AutoIt 3.3.9.2 beta to run the UDF. Could you give it a try?

What could cause your problem is that you run the 64 bit version of Office. Even Microsoft recommends to use the 32 bit version.

Do you have a computer with Office 2010 32 bit available where you can test?

My office install is 32bit. Office 2007. My OS is 7 64bit, but that shouldn't hurt as I compile ll of my scripts as 32bit.

I am going to grab the UDF you linked to now and give it a shot. Thanks!

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

Mixed results. Your example in _Word_DocPrint.au3 works great, and even works great with the DOC file I am building with the script I want to print from. The oddity is that I have something in my script that is making your UDF unhappy, probably something left over from Word.au3. I have made sure the DOC file is closed, ran _WordQuit and even tried _WordErrorHandlerDeRegister(). When I do not kill the error handler from Word.au3 I get "The name of the active printer is: " but no name, if I kill the error handler the script dies at Local $sActivePrinter = $oDoc.Application.ActivePrinter. But within your example my printer is named properly and everything works....

SO, I obviously have some cleanup of my own script to do, your UDF seems to be working fine!

Thanks again

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

I think you shouldn't mix Word.au3 and WordEX.au3. Everything you can do with Word.au3 can be done with WordEX.au3 too.

I suggest to completely get rid of Word.au3.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I think you shouldn't mix Word.au3 and WordEX.au3. Everything you can do with Word.au3 can be done with WordEX.au3 too.

I suggest to completely get rid of Word.au3.

I definately thought that as well, but the way I am inserting images in to the document doesn't play friendly with your UDF.

$oWordApp = _WordCreate($sFilePath, 1, 0)
$oDoc = _WordDocGetCollection($oWordApp, 0)

For $a = 0 To 29
   If $PrintArray[$a][0] == "" Then
      $iLeft += 263
      If $iLeft > 600 Then
         $iLeft = 17
         $iTop += 97
      EndIf
   Else
      $oShape = $oDoc.Shapes.AddCanvas($oWordApp.PixelsToPoints($iLeft), $oWordApp.PixelsToPoints($iTop), $oWordApp.PixelsToPoints($iWidth), $oWordApp.PixelsToPoints($iHeight))
      $oTextbox = $oShape.CanvasItems.AddTextbox($wdTextOrientationVertical, 1, 1, $oShape.Width - 1, $oShape.Height - 1)
      $oRange = $oTextbox.TextFrame.TextRange
      _Word_DocPictureAdd($oDoc, @TempDir & "" & $placement[$a] & ".jpg", False, True, $oRange)
      $oTextbox.Line.Visible = False
      $iLeft += 263
      If $iLeft > 600 Then
         $iLeft = 17
         $iTop += 97
      EndIf
   EndIf
Next
_WordQuit($oWordApp, -1)

It's the _WordDocGetCollection that seems to be the problem, the way your new UDF specifies the range is different. I couldn't figure out how to make it happy and left it alone for a while, care to shed some light?

Thanks!

Ian

Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

It's the _WordDocGetCollection that seems to be the problem, the way your new UDF specifies the range is different. I couldn't figure out how to make it happy and left it alone for a while, care to shed some light?

But _WordDocGetCollection has nothing to do with ranges. It returns a document collection or the object of a single document. You specify 0 so you get the object of the current document.

Can you post a small reproducer script (the above script contains an undefined array) I can play with?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Sorry for the undefined array above, I guess I was just hoping you wouldn't need a full example :oops:

As you will see, the script is designed to fill a label sheet with product labels. The full script dynamically creates the labels, I attached a sample and ditched the array from above with the file name. The script works great as-is. but to print you have to open Word and print from there, which seems kinda silly.....

#include <Word.au3>
#include <WordEX.au3>

Const $wdTextOrientationHorizontal = 0
Const $wdTextOrientationUpward = 2
Const $wdTextOrientationDownward = 3
Const $wdTextOrientationVerticalFarEast = 1
Const $wdTextOrientationHorizontalRotatedFarEast = 4
Const $wdTextOrientationVertical = 5

Global $iLeft = 17, $iTop = 53, $iWidth = 243, $iHeight = 94
$sFilePath = @ScriptDir & "\Test Label Sheet.doc"
FileDelete($sFilePath)

$oWordApp = _WordCreate($sFilePath, 1, 0)
$oDoc = _WordDocGetCollection($oWordApp, 0)

For $a = 0 To 29
   $oShape = $oDoc.Shapes.AddCanvas($oWordApp.PixelsToPoints($iLeft), $oWordApp.PixelsToPoints($iTop), $oWordApp.PixelsToPoints($iWidth), $oWordApp.PixelsToPoints($iHeight))
   $oTextbox = $oShape.CanvasItems.AddTextbox($wdTextOrientationVertical, 1, 1, $oShape.Width - 1, $oShape.Height - 1)
   $oRange = $oTextbox.TextFrame.TextRange
   _Word_DocPictureAdd($oDoc, @ScriptDir & "\844660054467.jpg", False, True, $oRange)
   $oTextbox.Line.Visible = False
   $iLeft += 263
   If $iLeft > 600 Then
      $iLeft = 17
      $iTop += 97
   EndIf
Next
_WordQuit($oWordApp, -1)

ShellExecute($sFilePath)

Thanks!

Ian

post-49852-0-58391600-1346609388_thumb.j

Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

Thanks for the reproducer script.

I will test and come back with the results tomorrow.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This works fine for me:

#include <WordEX.au3>

Const $wdTextOrientationHorizontal = 0
Const $wdTextOrientationUpward = 2
Const $wdTextOrientationDownward = 3
Const $wdTextOrientationVerticalFarEast = 1
Const $wdTextOrientationHorizontalRotatedFarEast = 4
Const $wdTextOrientationVertical = 5

Global $iLeft = 17, $iTop = 53, $iWidth = 243, $iHeight = 94
$sFilePath = @ScriptDir & "Test Label Sheet.doc"
FileDelete($sFilePath)

$oWordApp = _Word_Create(1)
$oDoc = _Word_DocAdd($oWordApp)

For $a = 0 To 2
   $oShape = $oDoc.Shapes.AddCanvas($oWordApp.PixelsToPoints($iLeft), $oWordApp.PixelsToPoints($iTop), $oWordApp.PixelsToPoints($iWidth), $oWordApp.PixelsToPoints($iHeight))
   $oTextbox = $oShape.CanvasItems.AddTextbox($wdTextOrientationVertical, 1, 1, $oShape.Width - 1, $oShape.Height - 1)
   $oRange = $oTextbox.TextFrame.TextRange
   _Word_DocPictureAdd($oDoc, @ScriptDir & "844660054467.jpg", False, True, $oRange)
   $oTextbox.Line.Visible = False
   $iLeft += 263
   If $iLeft > 600 Then
      $iLeft = 17
      $iTop += 97
   EndIf
Next
_Word_DocPrint($oDoc, Default, Default, Default, Default, "Your printer name goes here")
_Word_Quit($oWordApp)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Great, thanks! I played with it, and noticed that I had to drop $iTop down 2 pixels and $iLeft left 9 pixels, and had to expand $iWidth to 250. Somehow the scale is also slightly smaller in your UDF, hard to be precise about it but the graphic is definitely slightly smaller using your UDF versus Wods.au3. However, that is not at all a problem, it is barely noticeable just something I caught. The only other thing I did was removed your "Your printer name goes here" and just used "" so it goes to the default printer.

I thank you very much for your help, and for the time you put in to this revised UDF!! I will also find the time to test with Office 2010 and if there is any issue I will let you know.

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

Glad to be of service :D

I will be glad for any feedback you can give to improve the UDF!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Sorry to report that we have an issue with Office 2010. I uninstalled my Office 2007 and downloaded Office 2010 Starter (http://www.downloadcrew.com/article/26083-microsoft_office_starter) and ran the script, got a failure:

$oShape = $oDoc.Shapes.AddCanvas($oWordApp.PixelsToPoints($iLeft), $oWordApp.PixelsToPoints($iTop), $oWordApp.PixelsToPoints($iWidth), $oWordApp.PixelsToPoints($iHeight))

That is the same message that is returned when the computer doesn't have Word 2003 or above, at least up to 2007. I also did verify that the 2010 that installed is 32bit. I know Office 2010 Starter is stripped-down, but have a hard time believing that they would have removed core API stuff. I don't have a full version, so there isn't much I can do to keep testing unless I can test on a customer's computer that has a full version of 2010 installed.

Ian

Edited by llewxam

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

IIRC the starter version misses the COM interface.

Check this

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...