Hi,

I'm developing an application which needs information from an word document. Currently, i'm opening it in editable for getting information. But, Sometimes when the Document is already opened an unexpected window with a message--Doument is already opened for editing.do you want to open it in read-only mode-- is getting displayed. So, to avoid this message, i want to open the document in Read-Only mode. Can someone do the needful...


Thanks,
Karthik

Recommended Answers

All 6 Replies

hi, it seems like your opening two files at the same time.... please review your code whether there's a line there that activates the file that is already opened.. :)

Sometimes too, if you make an object, and don't you clean it up (*ehem*), the object will stay in memory, and windows will flip out about it. For example, if you open a new word object, and don't delete it:

dim oApp 
set oApp = createobject("Word.Application")
end

Run that code in a test project. Go check the task manager. Go. Do It. Word is still running in the process list isn't it? Bad News.

dim oApp 
set oApp = createobject("Word.Application")
oApp.Quit
set oApp = nothing
end

Now try that one..... (don't forget to kill the copy of word from the previous application). Now word is no longer running in the process list when we quit our VB app.

I'm not saying this is what is happening to you. I won't know until you post your code for us, but it's something to check and be aware of.

Hi, It's like, people of my project opens the word document for editing from other machine as the word documents are in sharing.... so when i run the tool, for the test cases opened in other machine, unexpected window is getting displayed ... So,it became a big problem for me....Could you tell me to open the word document in Read-Only mode so that i can get the information from the document even it is opned for editing....


Thanks,
Karthik

hi Karthik, try this code..it's working,,,make sure you reference the microsoft word library in your vb app..

Dim apW As Word.Application
Dim Dcap As Word.Document
Dim strpath As String
strpath = "c:\asd.doc" 'Change filename and path to your desired location
Set apW = New Word.Application

Set Dcap = apW.Documents.Open(strpath, , True)
apW.Visible = True
Dcap.Activate

;)

Dim apw As Word.Application
Dim Dcap As Word.Document
Dim strpath As String
strpath = "c:\asd.doc" 'Change filename and path to your desired location
Set apW = New Word.Application

Set Dcap=apw.Documents.Open(strPath,True)
apw.Visible= True
Dcap.Activate


I knw this,bt i am not able to hold the add(ie strPath) from my .frm to .cls
Plz help wid that

Dim apw As Word.Application
Dim Dcap As Word.Document
Dim strpath As String
strpath = (App.path & "\asd.doc") 'Change filename and path to your desired location
Set apW = New Word.Application

Set Dcap=apw.Documents.Open(strPath,True)
apw.Visible= True
Dcap.Activate

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.