I'm showing the wdDialogFilePrint, but I would like to force
wdPrintDocumentWithMarkup. I tried something like:

Set didPrint = Dialogs(wdDialogFilePrint)
didPrint.Display
didPrint.Item = wdPrintDocumentWithMarkup
didPrint.Execute

but that doesn't work. :/

All the help I've seen suggests that I can only use
wdPrintDocumentWithMarkup with PrintOut. If true, will PrintOut use
the settings I've captured in the didPrint Dialog object?

Re: Force wdPrintDocumentWithMarkup by Jay

Jay
Tue Mar 20 22:37:39 CDT 2007

On 20 Mar 2007 14:02:42 -0700, cklester@gmail.com wrote:

>I'm showing the wdDialogFilePrint, but I would like to force
>wdPrintDocumentWithMarkup. I tried something like:
>
>Set didPrint = Dialogs(wdDialogFilePrint)
>didPrint.Display
>didPrint.Item = wdPrintDocumentWithMarkup
>didPrint.Execute
>
>but that doesn't work. :/
>
>All the help I've seen suggests that I can only use
>wdPrintDocumentWithMarkup with PrintOut. If true, will PrintOut use
>the settings I've captured in the didPrint Dialog object?

If you need to use wdPrintDocumentWithMarkup, you're stuck with using
the PrintOut method. The reason is a little complicated, and more than
a little stupid...

The parameters of the built-in dialogs in Word 97 and later are all
identical to the ones used in WordBasic in Word 95 and earlier. The
parameter of the wdDialogFilePrint dialog object that corresponds to
the Print What box in the dialog is named "Type". You can find this in
the FilePrint topic of the WordBasic help file, which is still
available for download from
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=1A24B2A7-31AE-4B7C-A377-45A8E2C70AB2.

The trouble with this is that in VBA, the Dialog object itself has a
Type property. The value of Dialogs(wdDialogFilePrint).Type is 88,
which is the value of the constant wdDialogFilePrint -- in other
words, it returns the answer to "what type of dialog is this?" This is
a read-only property, so code that _should_ work

Dim dlg As Dialog
Set dlg = Dialogs(wdDialogFilePrint)
With dlg
.Type = wdPrintDocumentWithMarkup
.Execute
End With

fails with a compile error "Can't assign to a read-only property".

What you can do instead is to use the .Display method of the dialog to
let the user set the desired controls, and then transfer the resulting
parameters to the PrintOut method, and add the
Item:=wdPrintDocumentWithMarkup parameter as you do that:

Dim dlg As Dialog
Set dlg = Dialogs(wdDialogFilePrint)
With dlg
If .Display = -1 Then
ActiveDocument.PrintOut _
Background:=True, _
Range:=.Range, _
from:=.from, to:=.to, _
Item:=wdPrintDocumentWithMarkup, _
Copies:=.numcopies, _
Pages:=.Pages
End If
End With

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

Re: Force wdPrintDocumentWithMarkup by Tony

Tony
Wed Mar 21 05:27:46 CDT 2007

> What you can do instead is to use the .Display method of the dialog to
> let the user set the desired controls, and then transfer the resulting
> parameters to the PrintOut method, and add the
> Item:=wdPrintDocumentWithMarkup parameter as you do that:
>
> Dim dlg As Dialog
> Set dlg = Dialogs(wdDialogFilePrint)
> With dlg
> If .Display = -1 Then
> ActiveDocument.PrintOut _
> Background:=True, _
> Range:=.Range, _
> from:=.from, to:=.to, _
> Item:=wdPrintDocumentWithMarkup, _
> Copies:=.numcopies, _
> Pages:=.Pages
> End If
> End With
>

Unfortunately this is not a perfect solution as error handling does not work
properly with the Display method. I have just checked and this is still the
case in Word 2007.

For example, if a user enters "abc" in the Pages box, the dialog recognises
the error and redisplays but without any error message. If the user manages
to correct the error the dialog will then show the error message it should
have shown earlier and return the error, rather than the correction, to the
VBA code.

So the method will work properly only if the user never makes a mistake :)

--
Enjoy,
Tony

"Jay Freedman" <jay.freedman@verizon.net> schreef in bericht
news:il8103l1q9uv1002065b28dphaikr4uk92@4ax.com...
> On 20 Mar 2007 14:02:42 -0700, cklester@gmail.com wrote:
>
>>I'm showing the wdDialogFilePrint, but I would like to force
>>wdPrintDocumentWithMarkup. I tried something like:
>>
>>Set didPrint = Dialogs(wdDialogFilePrint)
>>didPrint.Display
>>didPrint.Item = wdPrintDocumentWithMarkup
>>didPrint.Execute
>>
>>but that doesn't work. :/
>>
>>All the help I've seen suggests that I can only use
>>wdPrintDocumentWithMarkup with PrintOut. If true, will PrintOut use
>>the settings I've captured in the didPrint Dialog object?
>
> If you need to use wdPrintDocumentWithMarkup, you're stuck with using
> the PrintOut method. The reason is a little complicated, and more than
> a little stupid...
>
> The parameters of the built-in dialogs in Word 97 and later are all
> identical to the ones used in WordBasic in Word 95 and earlier. The
> parameter of the wdDialogFilePrint dialog object that corresponds to
> the Print What box in the dialog is named "Type". You can find this in
> the FilePrint topic of the WordBasic help file, which is still
> available for download from
> http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=1A24B2A7-31AE-4B7C-A377-45A8E2C70AB2.
>
> The trouble with this is that in VBA, the Dialog object itself has a
> Type property. The value of Dialogs(wdDialogFilePrint).Type is 88,
> which is the value of the constant wdDialogFilePrint -- in other
> words, it returns the answer to "what type of dialog is this?" This is
> a read-only property, so code that _should_ work
>
> Dim dlg As Dialog
> Set dlg = Dialogs(wdDialogFilePrint)
> With dlg
> .Type = wdPrintDocumentWithMarkup
> .Execute
> End With
>
> fails with a compile error "Can't assign to a read-only property".
>
> What you can do instead is to use the .Display method of the dialog to
> let the user set the desired controls, and then transfer the resulting
> parameters to the PrintOut method, and add the
> Item:=wdPrintDocumentWithMarkup parameter as you do that:
>
> Dim dlg As Dialog
> Set dlg = Dialogs(wdDialogFilePrint)
> With dlg
> If .Display = -1 Then
> ActiveDocument.PrintOut _
> Background:=True, _
> Range:=.Range, _
> from:=.from, to:=.to, _
> Item:=wdPrintDocumentWithMarkup, _
> Copies:=.numcopies, _
> Pages:=.Pages
> End If
> End With
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.


Re: Force wdPrintDocumentWithMarkup by Jay

Jay
Wed Mar 21 12:06:27 CDT 2007

> So the method will work properly only if the user never makes a
> mistake :)

A mistake? Moi? Never! ;-)

Tony Jollans wrote:
>> What you can do instead is to use the .Display method of the dialog
>> to let the user set the desired controls, and then transfer the
>> resulting parameters to the PrintOut method, and add the
>> Item:=wdPrintDocumentWithMarkup parameter as you do that:
>>
>> Dim dlg As Dialog
>> Set dlg = Dialogs(wdDialogFilePrint)
>> With dlg
>> If .Display = -1 Then
>> ActiveDocument.PrintOut _
>> Background:=True, _
>> Range:=.Range, _
>> from:=.from, to:=.to, _
>> Item:=wdPrintDocumentWithMarkup, _
>> Copies:=.numcopies, _
>> Pages:=.Pages
>> End If
>> End With
>>
>
> Unfortunately this is not a perfect solution as error handling does
> not work properly with the Display method. I have just checked and
> this is still the case in Word 2007.
>
> For example, if a user enters "abc" in the Pages box, the dialog
> recognises the error and redisplays but without any error message. If
> the user manages to correct the error the dialog will then show the
> error message it should have shown earlier and return the error,
> rather than the correction, to the VBA code.
>
> So the method will work properly only if the user never makes a
> mistake :)
>
> "Jay Freedman" <jay.freedman@verizon.net> schreef in bericht
> news:il8103l1q9uv1002065b28dphaikr4uk92@4ax.com...
>> On 20 Mar 2007 14:02:42 -0700, cklester@gmail.com wrote:
>>
>>> I'm showing the wdDialogFilePrint, but I would like to force
>>> wdPrintDocumentWithMarkup. I tried something like:
>>>
>>> Set didPrint = Dialogs(wdDialogFilePrint)
>>> didPrint.Display
>>> didPrint.Item = wdPrintDocumentWithMarkup
>>> didPrint.Execute
>>>
>>> but that doesn't work. :/
>>>
>>> All the help I've seen suggests that I can only use
>>> wdPrintDocumentWithMarkup with PrintOut. If true, will PrintOut use
>>> the settings I've captured in the didPrint Dialog object?
>>
>> If you need to use wdPrintDocumentWithMarkup, you're stuck with using
>> the PrintOut method. The reason is a little complicated, and more
>> than a little stupid...
>>
>> The parameters of the built-in dialogs in Word 97 and later are all
>> identical to the ones used in WordBasic in Word 95 and earlier. The
>> parameter of the wdDialogFilePrint dialog object that corresponds to
>> the Print What box in the dialog is named "Type". You can find this
>> in the FilePrint topic of the WordBasic help file, which is still
>> available for download from
>> http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=1A24B2A7-31AE-4B7C-A377-45A8E2C70AB2.
>>
>> The trouble with this is that in VBA, the Dialog object itself has a
>> Type property. The value of Dialogs(wdDialogFilePrint).Type is 88,
>> which is the value of the constant wdDialogFilePrint -- in other
>> words, it returns the answer to "what type of dialog is this?" This
>> is a read-only property, so code that _should_ work
>>
>> Dim dlg As Dialog
>> Set dlg = Dialogs(wdDialogFilePrint)
>> With dlg
>> .Type = wdPrintDocumentWithMarkup
>> .Execute
>> End With
>>
>> fails with a compile error "Can't assign to a read-only property".
>>
>> What you can do instead is to use the .Display method of the dialog
>> to let the user set the desired controls, and then transfer the
>> resulting parameters to the PrintOut method, and add the
>> Item:=wdPrintDocumentWithMarkup parameter as you do that:
>>
>> Dim dlg As Dialog
>> Set dlg = Dialogs(wdDialogFilePrint)
>> With dlg
>> If .Display = -1 Then
>> ActiveDocument.PrintOut _
>> Background:=True, _
>> Range:=.Range, _
>> from:=.from, to:=.to, _
>> Item:=wdPrintDocumentWithMarkup, _
>> Copies:=.numcopies, _
>> Pages:=.Pages
>> End If
>> End With
>>
>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP FAQ: http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.



Re: Force wdPrintDocumentWithMarkup by Tony

Tony
Wed Mar 21 13:13:03 CDT 2007

LOL!

Not you, Jay, of course not you! It's those pesky users - I think they do it
on purpose <g>

--
Enjoy,
Tony

"Jay Freedman" <jay.freedman@verizon.net> schreef in bericht
news:%23NHuEt9aHHA.1300@TK2MSFTNGP02.phx.gbl...
>> So the method will work properly only if the user never makes a
>> mistake :)
>
> A mistake? Moi? Never! ;-)
>
> Tony Jollans wrote:
>>> What you can do instead is to use the .Display method of the dialog
>>> to let the user set the desired controls, and then transfer the
>>> resulting parameters to the PrintOut method, and add the
>>> Item:=wdPrintDocumentWithMarkup parameter as you do that:
>>>
>>> Dim dlg As Dialog
>>> Set dlg = Dialogs(wdDialogFilePrint)
>>> With dlg
>>> If .Display = -1 Then
>>> ActiveDocument.PrintOut _
>>> Background:=True, _
>>> Range:=.Range, _
>>> from:=.from, to:=.to, _
>>> Item:=wdPrintDocumentWithMarkup, _
>>> Copies:=.numcopies, _
>>> Pages:=.Pages
>>> End If
>>> End With
>>>
>>
>> Unfortunately this is not a perfect solution as error handling does
>> not work properly with the Display method. I have just checked and
>> this is still the case in Word 2007.
>>
>> For example, if a user enters "abc" in the Pages box, the dialog
>> recognises the error and redisplays but without any error message. If
>> the user manages to correct the error the dialog will then show the
>> error message it should have shown earlier and return the error,
>> rather than the correction, to the VBA code.
>>
>> So the method will work properly only if the user never makes a
>> mistake :)
>>
>> "Jay Freedman" <jay.freedman@verizon.net> schreef in bericht
>> news:il8103l1q9uv1002065b28dphaikr4uk92@4ax.com...
>>> On 20 Mar 2007 14:02:42 -0700, cklester@gmail.com wrote:
>>>
>>>> I'm showing the wdDialogFilePrint, but I would like to force
>>>> wdPrintDocumentWithMarkup. I tried something like:
>>>>
>>>> Set didPrint = Dialogs(wdDialogFilePrint)
>>>> didPrint.Display
>>>> didPrint.Item = wdPrintDocumentWithMarkup
>>>> didPrint.Execute
>>>>
>>>> but that doesn't work. :/
>>>>
>>>> All the help I've seen suggests that I can only use
>>>> wdPrintDocumentWithMarkup with PrintOut. If true, will PrintOut use
>>>> the settings I've captured in the didPrint Dialog object?
>>>
>>> If you need to use wdPrintDocumentWithMarkup, you're stuck with using
>>> the PrintOut method. The reason is a little complicated, and more
>>> than a little stupid...
>>>
>>> The parameters of the built-in dialogs in Word 97 and later are all
>>> identical to the ones used in WordBasic in Word 95 and earlier. The
>>> parameter of the wdDialogFilePrint dialog object that corresponds to
>>> the Print What box in the dialog is named "Type". You can find this
>>> in the FilePrint topic of the WordBasic help file, which is still
>>> available for download from
>>> http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=1A24B2A7-31AE-4B7C-A377-45A8E2C70AB2.
>>>
>>> The trouble with this is that in VBA, the Dialog object itself has a
>>> Type property. The value of Dialogs(wdDialogFilePrint).Type is 88,
>>> which is the value of the constant wdDialogFilePrint -- in other
>>> words, it returns the answer to "what type of dialog is this?" This
>>> is a read-only property, so code that _should_ work
>>>
>>> Dim dlg As Dialog
>>> Set dlg = Dialogs(wdDialogFilePrint)
>>> With dlg
>>> .Type = wdPrintDocumentWithMarkup
>>> .Execute
>>> End With
>>>
>>> fails with a compile error "Can't assign to a read-only property".
>>>
>>> What you can do instead is to use the .Display method of the dialog
>>> to let the user set the desired controls, and then transfer the
>>> resulting parameters to the PrintOut method, and add the
>>> Item:=wdPrintDocumentWithMarkup parameter as you do that:
>>>
>>> Dim dlg As Dialog
>>> Set dlg = Dialogs(wdDialogFilePrint)
>>> With dlg
>>> If .Display = -1 Then
>>> ActiveDocument.PrintOut _
>>> Background:=True, _
>>> Range:=.Range, _
>>> from:=.from, to:=.to, _
>>> Item:=wdPrintDocumentWithMarkup, _
>>> Copies:=.numcopies, _
>>> Pages:=.Pages
>>> End If
>>> End With
>>>
>>> --
>>> Regards,
>>> Jay Freedman
>>> Microsoft Word MVP FAQ: http://word.mvps.org
>>> Email cannot be acknowledged; please post all follow-ups to the
>>> newsgroup so all may benefit.
>
>


Re: Force wdPrintDocumentWithMarkup by cklester

cklester
Wed Mar 21 14:20:55 CDT 2007

On Mar 20, 10:37 pm, Jay Freedman <jay.freed...@verizon.net> wrote:
> On 20 Mar 2007 14:02:42 -0700, ckles...@gmail.com wrote:
> >I'm showing the wdDialogFilePrint, but I would like to force
> >wdPrintDocumentWithMarkup. I tried something like:
> >Set didPrint = Dialogs(wdDialogFilePrint)
> >didPrint.Display
> >didPrint.Item =wdPrintDocumentWithMarkup
> >didPrint.Execute
> >but that doesn't work. :/
> >All the help I've seen suggests that I can only use
> >wdPrintDocumentWithMarkupwith PrintOut. If true, will PrintOut use
> >the settings I've captured in the didPrint Dialog object?
>
> If you need to usewdPrintDocumentWithMarkup, you're stuck with using
> the PrintOut method. The reason is a little complicated, and more than
> a little stupid...
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ:http://word.mvps.org

Thanks, Jay, for the explanation and solution. :)



Re: Force wdPrintDocumentWithMarkup by cklester

cklester
Wed Mar 21 14:47:03 CDT 2007

On Mar 20, 10:37 pm, Jay Freedman <jay.freed...@verizon.net> wrote:
> If you need to usewdPrintDocumentWithMarkup, you're stuck with using
> the PrintOut method. The reason is a little complicated, and more than
> a little stupid...

Ummmm... trying to make this backward compatible and failing
miserably. Jay, can you revise it?

When used in, for example, Word 2000, wdPrintDocumentWithMarkup can
even be bypassed with On Error Resume Next. I figure I would assign it
to a variable and if it can't get assigned, that means it's < 2003. No
such luck.

Help?! :)


Re: Force wdPrintDocumentWithMarkup by Jay

Jay
Wed Mar 21 15:16:06 CDT 2007

cklester@gmail.com wrote:
> On Mar 20, 10:37 pm, Jay Freedman <jay.freed...@verizon.net> wrote:
>> If you need to usewdPrintDocumentWithMarkup, you're stuck with using
>> the PrintOut method. The reason is a little complicated, and more
>> than a little stupid...
>
> Ummmm... trying to make this backward compatible and failing
> miserably. Jay, can you revise it?
>
> When used in, for example, Word 2000, wdPrintDocumentWithMarkup can
> even be bypassed with On Error Resume Next. I figure I would assign it
> to a variable and if it can't get assigned, that means it's < 2003. No
> such luck.
>
> Help?! :)

Can you wait a few hours? I'm at work now, where I have only Word 2003 to
play with. When I get home I can try other versions (Virtual PC is good that
way!).

Meanwhile, you can check explicitly what version is running your code by
interrogating the value of Application.Version. It returns a string, such as
"11.0" for Word 2003 or "9.0" for Word 2000. Use that in an If statement to
execute one or the other copy of the PrintOut method.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.



Re: Force wdPrintDocumentWithMarkup by Jay

Jay
Wed Mar 21 21:10:01 CDT 2007

On Wed, 21 Mar 2007 16:16:06 -0400, "Jay Freedman"
<jay.freedman@verizon.net> wrote:

>cklester@gmail.com wrote:
>> On Mar 20, 10:37 pm, Jay Freedman <jay.freed...@verizon.net> wrote:
>>> If you need to usewdPrintDocumentWithMarkup, you're stuck with using
>>> the PrintOut method. The reason is a little complicated, and more
>>> than a little stupid...
>>
>> Ummmm... trying to make this backward compatible and failing
>> miserably. Jay, can you revise it?
>>
>> When used in, for example, Word 2000, wdPrintDocumentWithMarkup can
>> even be bypassed with On Error Resume Next. I figure I would assign it
>> to a variable and if it can't get assigned, that means it's < 2003. No
>> such luck.
>>
>> Help?! :)
>
>Can you wait a few hours? I'm at work now, where I have only Word 2003 to
>play with. When I get home I can try other versions (Virtual PC is good that
>way!).
>
>Meanwhile, you can check explicitly what version is running your code by
>interrogating the value of Application.Version. It returns a string, such as
>"11.0" for Word 2003 or "9.0" for Word 2000. Use that in an If statement to
>execute one or the other copy of the PrintOut method.

OK, the light dawns...

In Word 2000, there is no way to toggle the visibility of tracked
changes; either they're visible, or they've been accepted/rejected.
Extending that to printing, there's no choice in the Print dialog to
print with or without markup; you get what's visible in the document.

In VBA, Word 2000 has no such constant as wdPrintDocumentWithMarkup,
as you can see by looking at the members of the WdPrintOutItem
collection in the object browser. In later versions that constant has
the value 7, while in Word 2000 the valid values are only 0 through 6.

A macro like this should work in either version, as I mentioned
before:

Sub foo()
Dim dlg As Dialog
Set dlg = Dialogs(wdDialogFilePrint)
With dlg
If .Display = -1 Then
If Val(Application.Version) > 9# Then
ActiveDocument.PrintOut _
Background:=False, _
Range:=.Range, _
from:=.from, to:=.to, _
Item:=wdPrintDocumentWithMarkup, _
Copies:=.numcopies, _
Pages:=.Pages
Else
' let the Item parameter default
' to wdPrintDocumentContent
ActiveDocument.PrintOut _
Background:=False, _
Range:=.Range, _
from:=.from, to:=.to, _
Copies:=.numcopies, _
Pages:=.Pages
End If
End If
End With
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

Re: Force wdPrintDocumentWithMarkup by cklester

cklester
Fri Mar 23 09:48:55 CDT 2007

On Mar 21, 9:10 pm, Jay Freedman <jay.freed...@verizon.net> wrote:
>
> A macro like this should work in either version, as I mentioned
> before:

The reason that code won't work in Word 2000 (at least it doesn't work
for me) is because wdPrintDocumentWithMarkup looks like an undefined
variable, so I get the "Compile Error: Variable Not Defined" message.
You said that constant has a value of 7, so I just replaced the
variable name with the value 7 and it seems to work in 2000. I haven't
tested that in 2003 yet, but I will today.

Thanks for the help! :)


Re: Force wdPrintDocumentWithMarkup by Jay

Jay
Fri Mar 23 16:13:27 CDT 2007

cklester@gmail.com wrote:
> On Mar 21, 9:10 pm, Jay Freedman <jay.freed...@verizon.net> wrote:
>>
>> A macro like this should work in either version, as I mentioned
>> before:
>
> The reason that code won't work in Word 2000 (at least it doesn't work
> for me) is because wdPrintDocumentWithMarkup looks like an undefined
> variable, so I get the "Compile Error: Variable Not Defined" message.
> You said that constant has a value of 7, so I just replaced the
> variable name with the value 7 and it seems to work in 2000. I haven't
> tested that in 2003 yet, but I will today.
>
> Thanks for the help! :)

Ah, I know what happened.

You have Option Explicit at the top of your module to tell VBA to consider
undeclared variables as errors. That's highly recommended, and I normally
use it in Word 2003 and 2007, the programs I use all the time.

However, I have a copy of Word 2000 installed in a Virtual PC partition,
which I use maybe five times a year. I didn't notice while I was testing
this code that I don't have Option Explicit turned on there. (Curses to MS
for not having it turned on by default...) So VBA just assumed that
wdPrintDocumentWithMarkup was an undeclared variable, initialized it to 0,
and proceeded. Since the code didn't execute that line, it all looked good.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.