Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Controling Printer and Word 97

Posted on 1999-01-26
4
Medium Priority
?
205 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 450 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

618 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