Bypass 'Open as read-only?' dialog from VBA

H

HFSchreiner

Hi,

I am using MS Word 2002 SP3, XP Pro

I am using VBA to insert a number of boiler plates (in a pre-defined list)
into a blank document.

Prior to inserting the boiler plate, the code needs to check the
boilerplates' margin and orientation properties in order to adjust same in
the receiving doc.

I have saved all boiler plates with 'Tools/Options/Security/File sharing
options for this document' set to read-only; to require user to explicitly
open as read-write to (help) prevent the saving of all but explicit changes.

Upon execution of:

' get boilerplate first section margins and orientation
Set oBoilerPlate = Documents.Open(Filename:=sBPFilePath, Visible:=False)
' open the boiler plate
With oBoilerPlate.Sections.First.PageSetup
propBPLeftMargin = .LeftMargin
propBPRightMargin = .RightMargin
propBPOrientation = .Orientation
End With
oBoilerPlate.Close (wdDoNotSaveChanges)

the user is presented with the:
'[filename]... should be opened as read-only unless changes to it need to be
saved. Open as read-only?' dialog.

Is there a method to bypass this dialog?
It would not be a bother, had I only to insert a few boiler plates, but
there can be as many as 150...

(I realize that there is a .dll from Microsoft to allow file property
changes from code - I am trying to avoid going that route because of
potential distribution/installation problems).

Your help is Greatly appreciated!

Thank you!

Fred Schreiner
 
S

Stuart

Just a thought...Have you tried adding Application.DisplayAlerts=wdAlertsNone
to the top of your code?

Stuart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top