Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / April 2006

Tip: Looking for answers? Try searching our database.

Referencing Word documents from VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg Wallace - 02 Apr 2006 21:37 GMT
In order to reference Word in VB, I have to add a reference to --

Microsoft Word 11.0 Object Library <-- I'm using Office 2003

Then, in my VB program, I'm forced to declare variables using the following
syntax --

Dim newdoc As New Microsoft.Office.Interop.Word.Document

In a book I'm using to learn VB 2003 (my last VB work was in 5.0), it shows
that one should be able to simply say

Dim newdoc as New Word.Document

When I look at the Microsoft.Office.Interop.Word Assembly, it has 4
assemblies --

Microsoft
Microsoft.Office
Microsoft.Office.Interop
Microsoft.Office.Interop.Word

Only the latter has any classes, etc. under it.  The others appear to be
empty namespaces.  Is having all of those extra entries why I can't use the
shorthand Word.Document in my DIM statements?  If so, is my setup fouled up
some way, or is it this way in all VB 2003 .NET installations?  Any help
greatly appreciated.
Signature

Greg Wallace

Helmut Obertanner - 09 Apr 2006 14:03 GMT
Hello Greg,

I'm a C# geek, but I'm sure you could use a statement like:

Imports Word = Microsoft.Office.Interop.Word

Sometimes it's better to use the full namespaces, because e.g. I can create
a namespace X4U.Word in my application.
Then the compiler doen't know wich object to use - Microsofts or mine.
Thats the reason for using long namespaces.

hope this helps,
Signature

Helmut Obertanner
Senior Developer
MVP - Visual Developer VSTO

http://www.x4u.de

> In order to reference Word in VB, I have to add a reference to --
>
[quoted text clipped - 23 lines]
> some way, or is it this way in all VB 2003 .NET installations?  Any help
> greatly appreciated.
Greg Wallace - 09 Apr 2006 18:03 GMT
Beautiful!  That worked perfectly.  I went back through the 4 sample projects
I had worked on and made the appropriate correction.  I didn't know you could
assign synonyms like that in an imports statement!
--
Thanks a lot!,
Greg Wallace

> Hello Greg,
>
[quoted text clipped - 36 lines]
> > some way, or is it this way in all VB 2003 .NET installations?  Any help
> > greatly appreciated.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
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.