Solved

Check if a MS-Word file is already opened

Posted on 2003-12-10
7
206 Views
Last Modified: 2010-05-03
I'm automating MS Word from VB6. I want to check if a document is already opened by another instance of Word (on the same or different computer). On my machine each time i open a word doc a hidden file is created:  "~$filename.doc", so i can check for excistence of this file. is this the same for all MS word versions and settings, or is a better procedure available for this check.
0
Comment
Question by:m_wendy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 250 total points
ID: 9919787
Try this

Open "yourfullpath file.doc" For Binary Access Read Lock Read As #1


Error will occur if file is opened by word
0
 

Author Comment

by:m_wendy
ID: 9963331
Ok this the first step, but i also want to be able to open the file in read-only mode if another user also has the file open in Read-only mode...
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9963616
IF you want to open the word doc, you should use word automation

ie


Wrdapp.Documents.Open FileName:="your odc.doc", ConfirmConversions:=False, _
        ReadOnly:=true

where Wrdapp is word.application

The OS allows only 1 people open for write but no limitiation for people open for read only.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:m_wendy
ID: 9973039
i know that i have to use automation... but i want to check the file before it is opened...
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9973375
Use my first comment
0
 
LVL 27

Expert Comment

by:planocz
ID: 10270435
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
No response from m_wendy from 12/19/2003 comment
Award points to EDDYKT is recommend.
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

planocz
EE Cleanup Volunteer
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question