Discussion:
Open a word document from addin
(too old to reply)
b***@gmail.com
2007-09-20 14:16:55 UTC
Permalink
I'm sorry to ask this totally lame question, but i cannot find any
documentation. I have written an addin that works as an ftp client,
and i would like the addin to be able to open a word document by
double clicking that item in one of my listviews. I am working with
Word in office 2007, VS2005, VSTO2005, and the PIA's, and coding in
c#.
Thankyou in advance
-Rob
Shauna Kelly
2007-09-21 11:32:19 UTC
Permalink
Hi

You need the Documents.Open method.

In VBA it would be something like:

Sub OpenDocument()

Dim sPFN As String
Dim oDoc As Word.Document
Dim wdApp as word.Application

'Get a reference to a Word application
set wdApp = where ever you're getting that from

'Get the path and file name from somewhere
sPFN = "C:\My folder\My subfolder\MyDocument.doc"

'Open the document
Set oDoc = wdApp.Documents.Open(FileName:=sPFN)

'You can now do stuff to the document


End Sub

You'll need to translate to C# and add appropriate error checking.

There are many parameters to the .Open method - look up Word VBA help for
the full details.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
Post by b***@gmail.com
I'm sorry to ask this totally lame question, but i cannot find any
documentation. I have written an addin that works as an ftp client,
and i would like the addin to be able to open a word document by
double clicking that item in one of my listviews. I am working with
Word in office 2007, VS2005, VSTO2005, and the PIA's, and coding in
c#.
Thankyou in advance
-Rob
Loading...