Ignoring "Read-Only/Notify" alerts when opening Word docs

J

Jills2000

Hi,

I am new to VBA and am having problems with writing code to open word
documents in VBA. Any help would be appreciated!

My code traverses through a specified folder and finds all the Word
documents located there. When it finds these docs, it opens each in
turn and executes some code accordingly.

The problem is that if somebody is currently using that file a dialog
box comes up asking the user whether they want to open the file in
"Read-Only" or "Notify when read/write is available" mode. This causes
my program to stall until the user makes a selection.

I have been trying to get the DisplayAlerts property to stop this
message box from coming up, but with no luck.

Can somebody tell me if I'm doing something wrong??

Thanks heaps in advance

Jill

*******SAMPLE CODE********************

Sub FindLinkedDocuments()

Word.Application.Visible = False
Application.ScreenUpdating = False
Word.Application.DisplayAlerts = wdAlertsNone
Excel.Application.DisplayAlerts = False

<my code>

Word.Application.DisplayAlerts = wdAlertsAll
Excel.Application.DisplayAlerts = True
Application.ScreenUpdating = False
Word.Application.Visible = True


End Sub
 
C

Cindy M -WordMVP-

Hi Jills2000,
The problem is that if somebody is currently using that file a dialog
box comes up asking the user whether they want to open the file in
"Read-Only" or "Notify when read/write is available" mode. This causes
my program to stall until the user makes a selection.

I have been trying to get the DisplayAlerts property to stop this
message box from coming up, but with no luck.
Certain dialog boxes can simply not be surpressed. Word was never
designed to work without user intervention. See if the technique in the
KB Article is any help

HOWTO: Dismiss a Dialog Displayed by Office Application with VB
[Q259971]
http://support.microsoft.com?kbid=259971

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
J

Jonathan West

Hi Jill,

Unfortunately, there are quite a few alerts that DisplayAlerts doesn't
suppress. This is one of them.

This article will show you how to detect whether a document is in use before
you try to open it.

How to check if a file has already been opened by another user
http://www.mvps.org/word/FAQs/MacrosVBA/CheckIfFileOpen.htm

If you check the file first, you can then avoid opening problem files and
therefore not trigger the alert
 

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