Word document disappearing trick

The Stoat

The Grim Squeaker
Local time
Today, 12:44
Joined
May 26, 2004
Messages
239
Hi all,

I've got a bit of an odd problem.

I'm trying to use this code to open a word document whose path is stored in the DB and displayed in a text box on my form.

Code:
Private Sub CMD_OPEN_FILE_DIALOG_Click()
Dim WordObj As Object
Dim StrOpenFile As String


StrOpenFile = Nz(Me.TXT_COMPETENCY_PATH, "")

If StrOpenFile <> "" Then

Set WordObj = CreateObject("word.Application")

    WordObj.Documents.Open StrOpenFile

Set WordObj = Nothing

End If
    
End Sub

When i click the cmd button the doc doesn't open but if i click the button again it says the document is open and locked for editing by me and gives me three options one of which is to view the doc in read only mode. If i select this then the document appears.

Any clues as to why i can't see it the first time of asking :confused:


Thanks

TS
 
Visible Word Document

Try adding

WordObj.visible = true

straight after the open line e.g.

WordObj.Documents.Open StrOpenFile
WordObj.visible = true

Brian
 
:) :) :) :)


Thanks very much.


TS
 

Users who are viewing this thread

Back
Top Bottom