-
[RESOLVED] [2005] Microsoft Word Reference Problem
I've got Office 2003 (fully patched etc..)
I simply want to add a reference to word in my .NET application.
I started a new project, Add Reference and browsed to: MicroSoft Word 11.0 Object Library and clicked OK.
I've got 2 warnings:
Cannot find wrapper assembly for type library "Word"
The referenced component "Word" could not be found
Everything seems to be ok (i.e. I can open Word by itself and it's installed in the standard directory).
If I go to Project - Properties - References, it says that it can't find the reference specified.
I don't know how to solve this problem. I've been searching but i must be doing something wrong. Can someone help me please?
Thanks,
edit Actually, just out of interest i tried to add an excel reference and it's not working either so it's a general problem rather than specific to Word.
-
Re: [2005] Microsoft Word Reference Problem
What if you try to add it to a new project?
-
Re: [2005] Microsoft Word Reference Problem
That's what I did, it was a new project to begin with. I closed Studio down, no office programs are running either, re-opened VS, and then created a new project and tried to add the reference. There's no code yet been added. Totally new.
I'll give my computer a restart (not that i think it will help but hey....)
-
Re: [2005] Microsoft Word Reference Problem
Just seen your Edit and was wondering if it also affects any reference other then Office ones?
-
Re: [2005] Microsoft Word Reference Problem
I'm not sure, I added two .dll files (Apple quicktime library files) and they added fine. Added an Adobe Reader reference and it was fine.
I then tried a few others and they are giving the same messages as above although without the wrapper message.
However, if I write Imports .... they appear as you would expect. (the office ones don't).
What's going on?!? Please don't tell me I have to re-install visual studio! I hate doing that. It takes forever.
-
Re: [2005] Microsoft Word Reference Problem
Sounds like something is awry with VS and not Office then. If you can do without adding references for a while then I guess thats fine until you get the time to re-install or do a repair of VS. :(
-
Re: [2005] Microsoft Word Reference Problem
There goes my Friday night :cry: :eek2:
-
Re: [2005] Microsoft Word Reference Problem
Should take less then 1 hour unless you are running an older AMD. An Intel chip will make short work of repairing VS. :D
-
Re: [2005] Microsoft Word Reference Problem
I did the repair and it hasn't solved it.
I'm going to uninstall and reinstall Office first of all before I finally have to reinstall VS if it comes to it.
-
Re: [2005] Microsoft Word Reference Problem
Why dont you want to use Outlook 2003?
-
Re: [2005] Microsoft Word Reference Problem
sorry Rob, I don't know what you mean. What has Outlook got to do with it?
-
Re: [2005] Microsoft Word Reference Problem
Oops, sorry. Wrong thread. Was thinking of another thread with references pointing to Outlook 12 vs 11 in a mixed version environment.
-
Re: [2005] Microsoft Word Reference Problem
No problem. :)
Rob, while you are here can I ask a quick question about your office development FAQ. The reason i want to add a word reference is because a friend of mine wants to get info from an access database and then export it to word. I said I'd help. I can do the DB stuff but I've never placed data into a Word doc before. Your example is in VB6 - is the code for VB 2005 any different or pretty much the same?
Anything i should be aware of or can you point me to a good resource that you know of?
-
Re: [2005] Microsoft Word Reference Problem
When you add referenc to the MS Word do you get one reference or three. I just refernced it and got three without any warnings.
-
Re: [2005] Microsoft Word Reference Problem
Is that from the Project - Properties - References - bit?
I only got 1. The MS Word 11.0 Object Library Reference (version 8.3.0.0)
I'm in the middle of re-installing Office at the moment. Will post back in a bit with news...
oh btw, what's the full reference path?
C:\Windows\assembly\...... ??
-
Re: [2005] Microsoft Word Reference Problem
Yes, I just referenced the Word 11.0 Object Library and got three of them at onec. I think you shold have these references in order to be able to use the word.
-
Re: [2005] Microsoft Word Reference Problem
Good news, the uninstall/re-install of Office did the trick. It seems to be working now.
Strange stuff indeed.
Thanks for your time.
-
1 Attachment(s)
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
You should get just this in the soution explorer.
-
Re: [2005] Microsoft Word Reference Problem
Quote:
Originally Posted by stimbo
I can do the DB stuff but I've never placed data into a Word doc before. Your example is in VB6 - is the code for VB 2005 any different or pretty much the same?
Anything i should be aware of or can you point me to a good resource that you know of?
The code is the same with the exceptions of no "Set" and the constants will be OOP'ed
-
1 Attachment(s)
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
I don't have that - I've got this after adding the word reference or this the same thing just without some of the reference path....
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
Do you have the Office PIAs installed? (link in my signature).
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
I think you need to check the "Microsoft.Office.Interapt.Word" check box in the "Imported Namespaces" List box under the Project property -> Reference
Edit * never mind.
-
1 Attachment(s)
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
No, I never have to check anything.
It looks like you dont have the PIAs.
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
You are right Rob. I noticed it too. Maybe restarting the windows and starting new project will fix this.
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
Quote:
Originally Posted by RobDog888
No, I never have to check anything.
It looks like you dont have the PIAs.
Rob what is the PIA's? I don't remember installing it. Does it come with the Office package?
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
Office Programmibility Interface Assemblies. They are a included but not default installed option when installling Office. You need to select them in the custom install.
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
I see, I remember installing the office as full so I guess it included it. Thank for the info.
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
One easy way to tell is if you type in the general declarations section the ...
Imports Microsoft.Office.Interop and you get the intellisense for .Interop.
If you only get.Core then you dont have it.
-
1 Attachment(s)
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
I just can't get this working. I followed the instructions and think i did everything correctly in regards to installing the PIA's
EDIT Ah, hold on: I did what you said and both of them came up - Core and Interop
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
Rob,
at the top of my form when I type Imports , WORD should appear in the list, correct? Because it's not and my project explorer References bit still isn't showing anything like yours still (although i do have the Core and Interop paths available when I write out the path mentioned earlier).
I'm still getting what I had originally. I've just added a reference to Excel as well and nothing is coming up when i write an Imports statement there either. I did this on my work laptop ages ago and simply added the reference, and wrote imports ....... and everything worked with no trouble. This is my home computer
The copies of VS and Office are 100% totally legit in case anyone is wondering.
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
If you added the reference to Word then you should get a popup for Word after .Interop.
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
ok, it seems to be working. Thanks for being so patient! As a quick test I created a word doc in my documents and then used your vb6 code and it wrote out the text.
Oh, one final question if you don't mind.
2 Code:
oApp.Selection.GoTo What:=wdGoToLine, Which:=wdGoToLast
In 2005, what do I have to do here?
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
Cool, glad its finally working now. :)
Here is the .NET equilivalent since we are importing the .Interop class we can shorten the constants to just Word.xxxx
Code:
oApp.Selection.GoTo(What:=Word.WdGoToItem.wdGoToLine, Which:=Word.WdGoToDirection.wdGoToLast)
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
Ah, that makes sense.
So everytime it looks for a Ref of Object type I should type Word. and choose the appropriate object type it's looking for. Thanks once again.
-
Re: [RESOLVED] [2005] Microsoft Word Reference Problem
Yes, as long as you are importing the .Interop class. If you import all the way down to the .Word class then it shortens it by one more object cclass. Only drawback with that is that both .NET and Office have an "Application" object. so you may get some confusion by the compiler of which class an Application object belongs to. IMO, its always better and easier to only import down to the .Interop so each application class will be identified properly.