[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Controling Printer and Word 97

Posted on 1999-01-26
4
Medium Priority
?
206 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
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 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…
Suggested Courses

834 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