Hi,
Does anyone know how to open a shared, read-only MS Word document in MS Word outside of the application upon clicking a command button?

Any help would be really appreciated
Many, many thanks

You should be able to use some kind of control. I don't remember if there is a toolbox control for viewing office apps with VB or not.... you can also use scripting to do this.... but that will probably load word. There is a way though, using com objects.... I'll let you know if I find anything more.

Try googling for OLE control and visual basic. Tons and tons of answers.

hi friend,

1. in project menu>refferences> select .. microsoft word 9.0 object library

Private Sub Command1_Click()

Dim objWord As Word.Application
' this would be faster with a "with objWord" but for clarity I use the explicit

Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open "c:\sql performance tips.doc", , , True

End Sub

first i though to give u a sample program. but now found a source which is providing info what i want to prepare. just go through it.
http://www.nigelrivett.net/PrintToWord.html

enjoy programming with vb ..all the best

Hi there,
Many thanks for your recent help. The coding you provided worked amazingly. Will is still work if the document is password protected? Also the word documents I have are both a shared resource and password protected, will the code still work or will I need to code in the permissions/password?

many, many thanks

hi,

to open password protected doc. we should know the password of the doc.
set file ->save as (select doc file)->tools > general options . . in pass word to open give pwd as sri, select readonly -. reenter pwd
the try this code.

Private Sub Command1_Click()

Dim objWord As Word.Application
' this would be faster with a "with objWord" but for clarity I use the explicit

Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open "c:\sql performance tips.doc", , , True, "sri"

End Sub

study about, open method parameters.

for more info go through
http://www.word.mvps.org/FAQs/MacrosVBA/CheckIfPWProtectB4Open.htm

note: please,if possible let me know how to set doc file share.i know how we have share a folder, but not a file.

enjoy vb programming... all the best

Hi guys,

It is quite easy to open ms word document in vb6.

1. Include the "Microsoft Word 11.0 Object Library"
- version 11.0 for MS Office 2003 and 12.0 for MS Office 2007
2. Then put some command button or menu button to initiate the event:
e.g

Private Sub Command1_Click()
         Dim wrdApp As New Excel.Application
         wrdApp.Workbooks.Open App.Path & "Filename.doc"  
         wrdApp.WindowState = wdWindowStateMaximize
         wrdApp.Visible = True
       End Sub

Note: just change the "Filename" with your corresponding ms word doc file name.

Thants it!

Happy programming guys!


Jeff Sibal

@jeff.sibal thank you for your time writing this reply. However I would like to ask you that next time you check date of original post as like in this case, originally posted in 2005, original poster either already found solution or would not be interested in it after such a long time.
One more think I would like to ask you is to use code tags when you post any code, as [code] YOUR CODE HERE [/code]

Thank you and thread closed

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.