Run-time error 5895

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Run-time error 5895

Post by ABabeNChrist »

When using this code to open Print Preview and if document is protected I would then receive this error

Code: Select all

    If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
        ActiveDocument.Unprotect ""
    End If
    ActiveDocument.PrintPreview
I also tried
Application.PrintPreview = True
:scratch:

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Run-time error 5895

Post by HansV »

Do you have a particular reason for unprotecting the document before print previewing it?

I don't receive an error message when I run your code, by the way, whether the document is protected for forms or not.
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Run-time error 5895

Post by ABabeNChrist »

Hi Hans
the only reason I was using any code to unprotect was that when document was unprotected prior to selection it worked good, it was only when document was protected before selection that the error would appear.

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Run-time error 5895

Post by HansV »

I can't reproduce the error. If you wish, you can post a stripped down copy of the document - you can remove as much as you want from the copy, as long as the error still occurs.
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Run-time error 5895

Post by ABabeNChrist »

Hi Hans
I can’t seem to get file small enough
Maybe this may help. I’m using Office 2007 Custom UI Editor to set up my custom tool bar and I’m using

Code: Select all

<button id="customButton9" label="Print Preview" size="large" onAction="OpenPrintPreview" image="blue" />
and from there I was using the code
Is it possible to use something like

Code: Select all

<control idMso="PrintPreview" size="large" />
using the build in features

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Run-time error 5895

Post by HansV »

I don't know, I have never customized the ribbon. Sorry.
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Run-time error 5895

Post by ABabeNChrist »

I found what I was looking for, I was close

Code: Select all

<control idMso="FilePrintPreview" size="large" label="Print Preview" />