Solved

Controling Printer and Word 97

Posted on 1999-01-26
4
196 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now