Solved

Check if a MS-Word file is already opened

Posted on 2003-12-10
7
202 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
  • 3
  • 2
7 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:m_wendy
Comment Utility
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
Comment Utility
Use my first comment
0
 
LVL 27

Expert Comment

by:planocz
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now