Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Open a word document from addin

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bickel.rob@gmail.com - 20 Sep 2007 15:16 GMT
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 - 21 Sep 2007 12:32 GMT
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

> 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,
[quoted text clipped - 4 lines]
> Thankyou in advance
> -Rob
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.