Dialogs(wdDialogFileOpen).Show ignores ReadOnlyRecommended

G

GRox

I really need some helpful hints (Word 2000, VBA):

I'm saving the documents with "ActiveDocument.SaveAs strFullPath & "\" &
strFileName, , , , , , True".

Using the Menu-Item FileOpen or the Windows-Explorer, the dialog referring
to the "ReadOnlyRecommended"-property is properly shown.

The vba command "Dialogs(wdDialogFileOpen).Show" always opens the document
write-protected without asking the user what to do !?

Is there any way to ask the user for a decision using the wdDialogFileOpen ?

Thanks a lot !
Guido
 
D

Doug Robbins - Word MVP

The following comes close to presenting the user with the same choices as if
the document was opened manually

Dim doc As Document
With Dialogs(wdDialogFileOpen)
If .Display <> -1 Then
Browsefile = ""
Else
Browsefile = WordBasic.FileNameInfo$(.Name, 1)
End If
End With
Set doc = Documents.Open(Browsefile)
If doc.ReadOnly = True Then
Response = MsgBox(Browsefile & "should be opened as
ReadabilityStatistic-only unless changes to it are to be saved. Open as
read_only?", vbYesNo + vbQuestion + vbDefaultButton1)
If Response = vbNo Then
doc.Close wdDoNotSaveChanges
End If
End If


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

GRox

Sorry, but this doesn't ssem to work:
If the user agrees, the document is - still - write protected, and if he
doesn't, the document will be closed without saving.

My first attempt with doc.unprotect instead of doc.close doesn't work,
anyway ?

While several users get a grip to the documents, I'd like the current user
to decide, wether or not he wants the choosen document to be edited or not -
but this doesn't seem to work ?

Have you got any ideas or further hints for me ?
 
D

Doug Robbins - Word MVP

Sorry, I said it came close. I do not know how to change the setting using
VBA.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

GRox

After several attempts I found out that even 'documents.open' ignores
'ReadOnlyRecommended' (http://support.microsoft.com/kb/275976/de). The only
way seems to be using 'good old' WordBasic:

So right after your 'doc.close' I now use

WordBasic.FileOpen Name:="Filename.doc"

so if the user says 'no' the document will be opened without any protection
!?

Thanks a lot for your help !
 
D

Doug Robbins - Word MVP

Thanks for posting back with this information. You may then want to modify
the code so that it replicates what happens when the document is opened
manually, giving the Yes, No or Cancel options:

Dim doc As Document
With Dialogs(wdDialogFileOpen)
If .Display <> -1 Then
browsefile = ""
Else
browsefile = WordBasic.FileNameInfo$(.Name, 1)
End If
End With
Set doc = Documents.Open(browsefile)
If doc.ReadOnly = True Then
Response = MsgBox(browsefile & "should be opened as Read only unless
changes to it are to be saved. Open as read_only?", vbYesNoCancel +
vbQuestion + vbDefaultButton1)
If Response = vbNo Then
doc.Close wdDoNotSaveChanges
WordBasic.FileOpen Name:=browsefile
ElseIf Response = vbCancel Then
doc.Close wdDoNotSaveChanges
End If
End If


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

GRox

That's nearly what I am doing now (fighting a vba-bug with a wordbasic-bug,
isn't it ?!), unless I use

browsefile = .Name instead of browsefile =
WordBasic.FileNameInfo$(.Name, 1)

and no Cancel-Option.

Thanks again - and: I'll promise to improve my English ;-)
 

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