Solved

Controling Printer and Word 97

Posted on 1999-01-26
4
201 Views
Last Modified: 2010-04-16
Is it possible to control Word 97 ( file open, print, etc...) and to set the default printer to a different one then it is right now with Visual C++ 5??

I'm using NT4 if that changes anything...

Thanks.
0
Comment
Question by:maximebrunet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 1185143
This is a bunch of tasks that can't be performed in a single step ;-)
Do you mean to 'fully' control Word (emulating user interaction etc.) or is it enough just to print a document (to a special printer)?
0
 

Author Comment

by:maximebrunet
ID: 1185144
Yes, Emulating user interaction...I want the software to open word, print to a the Acrobat PDFWriter printer, change the printer back to what it was and close the software.

I want to do that with the whole office suite...is it possible. Even not in one step?
0
 
LVL 86

Expert Comment

by:jkr
ID: 1185145
Emulating user interaction is hard. But maybe the OLE automation interface of the office applications might come inhady (though i never used it...)
0
 
LVL 2

Accepted Solution

by:
amitc011599 earned 150 total points
ID: 1185146
It is simplier to do it through Visual Basic or VBScript(usinh WSH) using the COM interface that Word 97 exposes. Also, use SR 1 for Office 97 or later.

Here is the code example:

   Sub SwitchPrinter()
      Dim strActivePrinter As String

      Set Application = CreateObject("Word.Application")

      ' Get active printer.
      strActivePrinter = Application.ActivePrinter

      ' Change to the printer to the 6P printer on the computer \\FLAMINGO
      Application.ActivePrinter = "\\FLAMINGO\HP LaserJet 6P/6MP"

      ' Print the active document to printer.
      ActiveDocument.PrintOut

      ' Change back to the default printer.
      Application.ActivePrinter = strActivePrinter

   End Sub

Note, the same is possible through VC++, get the CLSID from the registry, use CoCreateInstance and then go ahead. Use OLEVIEW to get more details on the COM interface.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question