Sonny Falk
24-Jan-2005, 01:57 PM
I googled this one and it seems like this is a known behavior of the
ActivePrinter property in Word. See
http://support.microsoft.com/kb/q216026/.
They seem to refer to the old obsolete interface in Word to work around
this problem. Word97 used to have one massive flat interface instead of
the more object oriented interface you see in more recent versions of
Word. It's still available for backwards compatibility, so you can use
that. This obsolete interface is marked as such in the type library, so
the Studio doesn't generate the code for that class. However, you can
easily generate the code for this deprecated class using an older
version of the Word type library.
I'm attaching an older version of the Word type library here. Just save
it somewhere and Select Import Automation Library in the Studio. Then
select the Browse button, and browse to the type library file. Then
place a Use statement in your code for this pkg. This will bring in the
old interface. In your regular Word Application object, there's a
function called ComWordBasic. This function will return an object of the
old deprecated interface.
I haven't tried this, so I'm not sure it actually works, but it should
be something like this:
Procedure PrintTheDoc
Handle hoWdBasic
Variant vWdBasic
Get Create U_cComWordBasic to hoWdBasic
Get ComWordBasic oMyWordAppObj to vWdBasic
Set pvComObject of hoWdBasic to vWdBasic
Send ComFilePrintSetup of hoWdBasic ...
...
Send Destroy to hoWdBasic
End_Procedure
Hope this helps.
-Sonny Falk (DAC)
> -----Original Message-----
> From: tbrannen [mailto:tbrannen@ate.net]
> Posted At: Monday, January 24, 2005 1:16 PM
> Posted To: visual-dataflex
> Conversation: How to get the default printer name
> Subject: How to get the default printer name
>
>
> Greetings,
> I have a way to select a printer using the VDF print
> dialog, but when I set the printer in Word using our
> Word8.pkg (FlexOle), it becomes the default printer for the
> computer. If I knew the original default printer, I could
> easily set it back to that on exiting, but I don't know how
> to get that information. There is a command
> "getglobalactiveprinter" in the Word8.pkg but it does not
> return anything. Neither does "getApplicationActivePrinter".
> Is there a way in just VDF to get that information? Maybe a
> call to windows API? Then I could get the current default
> printer as my view opens and save it as a property and reset
> it when the view closes.
>
> All help appreciated.
>
> Thanks,
>
> Tod Brannen
>
>
ActivePrinter property in Word. See
http://support.microsoft.com/kb/q216026/.
They seem to refer to the old obsolete interface in Word to work around
this problem. Word97 used to have one massive flat interface instead of
the more object oriented interface you see in more recent versions of
Word. It's still available for backwards compatibility, so you can use
that. This obsolete interface is marked as such in the type library, so
the Studio doesn't generate the code for that class. However, you can
easily generate the code for this deprecated class using an older
version of the Word type library.
I'm attaching an older version of the Word type library here. Just save
it somewhere and Select Import Automation Library in the Studio. Then
select the Browse button, and browse to the type library file. Then
place a Use statement in your code for this pkg. This will bring in the
old interface. In your regular Word Application object, there's a
function called ComWordBasic. This function will return an object of the
old deprecated interface.
I haven't tried this, so I'm not sure it actually works, but it should
be something like this:
Procedure PrintTheDoc
Handle hoWdBasic
Variant vWdBasic
Get Create U_cComWordBasic to hoWdBasic
Get ComWordBasic oMyWordAppObj to vWdBasic
Set pvComObject of hoWdBasic to vWdBasic
Send ComFilePrintSetup of hoWdBasic ...
...
Send Destroy to hoWdBasic
End_Procedure
Hope this helps.
-Sonny Falk (DAC)
> -----Original Message-----
> From: tbrannen [mailto:tbrannen@ate.net]
> Posted At: Monday, January 24, 2005 1:16 PM
> Posted To: visual-dataflex
> Conversation: How to get the default printer name
> Subject: How to get the default printer name
>
>
> Greetings,
> I have a way to select a printer using the VDF print
> dialog, but when I set the printer in Word using our
> Word8.pkg (FlexOle), it becomes the default printer for the
> computer. If I knew the original default printer, I could
> easily set it back to that on exiting, but I don't know how
> to get that information. There is a command
> "getglobalactiveprinter" in the Word8.pkg but it does not
> return anything. Neither does "getApplicationActivePrinter".
> Is there a way in just VDF to get that information? Maybe a
> call to windows API? Then I could get the current default
> printer as my view opens and save it as a property and reset
> it when the view closes.
>
> All help appreciated.
>
> Thanks,
>
> Tod Brannen
>
>