Solved

Controling Printer and Word 97

Posted on 1999-01-26
4
202 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

739 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