Need Help embeded word .tlh issue
I am attempting to reproduce ArticleID 309294 on http://support.microsoft.com/kb/30994/EN-US dealing with HOW TO: Handle Word Events by Using Visual C++ .NET and MFC.
I am using the Microsoft Word 10.0 Object Library <8.2> as the Type Library. When I compile using MS Visual Studio 8.0 compiler gives me thousands of errors all from the self generated msword.tlh file.
Any help would be greatly appreciated.
Thanks,
Bravo...
Re: Need Help embeded word .tlh issue
Word Event Listener Example
The link above has a stripped down example done with Visual Studio 2005 and Word 2000 attached as a zip file. Other than that you aren't giving us much to go on here.
Tom
Re: Need Help embeded word .tlh issue
There is not much to go on here as all I did was follow the instructions given by Microsoft and it doesn't work. Thanks for the sample!!! I will give it a go... Bravo!!!
Re: Need Help embeded word .tlh issue
The problem appears to only occur with Visual Studio 8.
I went back to Visual Studio 7 and it worked. (Yay)
I will try to import the project into Visual Studio 8 and see if it
works that way.
Its like slowly grinding a square peg in... Grrrrr...
Get the man a bigger hammer Franklin...
So long and thanks for all the fish...
Bravo!!!
Re: Need Help embeded word .tlh issue
Looks like I found my own solution...
These instructions are not applicable with Visual Studio 8 (VS8).
However using Visual Studio 7 (VS7) you can upgrade to VS8 and run the application from VS8. I'm not sure what the ramifications of this are.
Visual Studio 8 created a second folder off the WordEvents1 folder and put all its files except the suo, ncb and sln files in there ??? Curiosity got to me so I did a diff of the two projects files. There were many differences in the structure of the two projects. Even though the steps were similar and could be followed in both versions of visual studio. Looked like VS8 version included several functions overidden with 2008 and othe appendages added to their names???
I guess the bottom line it Visual Studio 8 is not backward compatible with this example for Visual Studio 7. Also learned that Visual Studio 8 will import and correctly compile the project if it was created in Visual Studio 7. NBC Go figure.
Thanks for all the fish.,
Bravo!!!
Re: Need Help embeded word .tlh issue
I have struggled down the same path with
Automate Microsoft Word to Perform a Mail Merge from Visual C++ .NET
http://support.microsoft.com/kb/308338/es
The page gives no clue that it does not work in VC 8.0. Like you, I followed the instructions exactly (at least 3 times to be sure) and ended up with 231 errors in the msword.tlh file.
Like you, I finally resorted to trying the thing using VC 7.0. And it worked just fine. I then ported the VC 7.0 version to VC 8.0 and, after VC 8.0 converted it, it again worked just fine (at least in the Release version).
Even in 8.0 debug version, you need to fiddle with the Manifester File by, 1 - Removing the ported one from the project, 2 - in the Properties/>Linker Manifest select Generate Manifest = 'Yes', and 3 - In the Properties
->Manifest Tool->Input and Output select Embed Manifest 'No'.
You will still get a bunch of First-chance exception messages:
First-chance exception at 0x7c812a5b in AutoProject.exe: 0x800706BA: The RPC server is unavailable. - but this does not seem to hinder the performance of the application.
Unlike you, it was not my curiosity that prodded me on but rather a genuine need to be able to use this type of Word Automation. I do not take kindly to people wasting my time, and the misinformation propagated by Microsoft regarding this issue has caused me to squander an entire workday. I really think that Microsoft needs to stop outsourcing this stuff to God knows where and get their act together.
FWIW, I still don't know how to build an MS Office Automation application in C++ using VC 8.0 and MSWORD.OLB. If anyone knows how, keep it to yourself, otherwise Microsoft might find out how to do it and charge us for the knowledge.
Mike :(
Re: Need Help embeded word .tlh issue
Looks like Visual studio 7 will be the only way to work with the embedded / Automation word / excel stuff. Just another flawed MS waste your time and money gotcha...
Thanks for all the info guys...
Bravo!!!
Re: Need Help embeded word .tlh issue
Well, there is a way to use VC 8.0. Build it it VC 7.0, then build an Automation enabled program in VC 8.0 and copy all of the generated typelibrary files that you need that was generated by VC 7.0. This works. Apparently, as you have pointed out, there is some problem with the way VC 8.0 builds the typelib files. :wave:
Re: Need Help embeded word .tlh issue
Actually I wanted to be able to get the Word events handled in an embeded application. I was hoping to use VS8 but can settle for VS7 until I get the shell working. I'm refering to combining Article ID : 316207 and 309294. I have combined the try block from EmbedAutomateWord() in 316207 with the try block OnBnClickedStartsink() in 309294. removing the second creation used by the event handling app. I have it to the point where it creates my application with the embeded word then it brings up another window with word and begins receiving messages sent by the second window. Looks like the m_wordApplication.put_Visible(TRUE); call actualy creates the new window and opens it. Then the rest of the code attaches the message pump to that window. My thinking is that there must be a function that just attaches to the existing document. So, that's what I'm looking for now??? Any ideas??? It is all appreciated...
Thanks,
Bravo!!!
Re: Need Help embeded word .tlh issue
So, today I went back and tried Article ID 178784 How to use automation to open and to print a Word document Using Visual Studio 6. It compiles using the Word 2007 olb (after much cajoling of the parameters to the open function) but gives a runtime error when it is run. I'm throwing in the towel on using word as an embeded object. I cannot get it to do one of the most simple things to open a document either embedded or not it simply refuses to cooperate. MS has their code AFU'd and I am so PO'd after wasting the past week trying to run their examples. If anyone has ever gotten a word document to open in an embedded word application please write to me. In the mean time I'm going to try a simpler approach and handle all of the editing myself as I'm running out of time with my tight deadline.
Thanks,
Bravo!!!
Re: Need Help embeded word .tlh issue
Quote:
Originally Posted by Mike Pliam
I have struggled down the same path with
Automate Microsoft Word to Perform a Mail Merge from Visual C++ .NET
http://support.microsoft.com/kb/308338/es
The page gives no clue that it does not work in VC 8.0.
From the bottom of that page...
Quote:
• Microsoft Visual C++ .NET 2002 Standard Edition
• Microsoft Foundation Class Library 4.2
• Microsoft Word 2000 Standard Edition
• Microsoft Word 2002 Standard Edition
• Microsoft Visual C++ .NET 2003 Standard Edition
• Microsoft Visual Studio .NET 2003 Professional Edition
• Microsoft Office Word 2003
Do you think it is necesary (or even possible to list all of the things an item will NOT work with??? :confused:
I dont see any difference in assuming that something writen for VC++ 7.0 would work for 8.0,9.0, or 10.0 (yes the CTP is out) than from assuming it would work on my 12 year old OS/2 based Watcom C++ compiler.....
Re: Need Help embeded word .tlh issue
Thanks for your input, Wiz.
Yes, I noticed that after I had posted but hardly thought it was worth mentioning, given the fact that there is so much confusing and misleading information generally in MSDN.
Pray tell, where is the MSDN page that demonstrates how to build an MS Word Automation client using VC 5.0 ? Can all of these others also be simply inexact in their searches ? Or is there some other problem inherent here?
Mike :(
Re: Need Help embeded word .tlh issue
Quote:
Originally Posted by Mike Pliam
given the fact that there is so much confusing and misleading information generally in MSDN.
Mike,
I am well aware that MSDN has serious "issues", but few people realize the magnidute of the task in keeping that much information even reasonably on-tract. Microsoft has a LARGE staff whos sole job is to organize and verify the content.
Up until recently (a few years IIRC) the practice was to keep only the "current" version content. This caused many issues, so it was decided to keep multiple versions, this lead to even more issues, so they put version cross references on much of the material.
A few things that I have found that make the experience a little better (although it takes a little effort..)
1) First try "F1" help against MSDN (locally or On-Line)
2) Second try searching directly from the MSDN page
3) Search from Google.
#1 will not be of much use for "concepts", but is a great starting point for specific reference material.
#2 and #3 work best in conjunction.
MSDN is heavily indexed by other means than page crawls. Therefore you will get matches that external search engines can not access.
Google will give many more hits, since it will include content that originates from so many other places. One way to help with this is to include "microsoft.com" in the query parameter.
If you get differing information, at least you know that such diferences exist, and will be more cautious of using the information.
Also, I (almost) always start by going to the bottom of any MSDN page, at looking at the "applies to". If it does not list the version I am using, then I know there may be problems.
Of course, there is always the "BEST" solution, which is to post here on CodeGuru. The odds are high that at least one of the regulars have experienced the same/similar problem with related page hits....
:wave: :wave:
Re: Need Help embeded word .tlh issue
You are absolutely correct. But when the old example doesn't work with the current compiler and current version of Word. Where do you turn and what do you do?
I've gone back thru 3 versions of VC and 4 versions of Word searching for what used to work in the hope of making it work with todays software. Now I've got the MSWord8.tlh or .olb file working with VS6.0. But this is not exactly what I wanted. I'd like to use a current version of Word with the current compiler software. To do the same type things I could do in 1998. But apparently MS has written all that off and now in 2008 you can't do any of that stuff you used to be able to do????
So, it's like what happened to the generated msword8.h and .cpp file that VS6 creates in VS 7.0 and VS 8.0? It no longer creates these. Oh yea it creates individual header files but try to use the _Application or _Document declarations and they will fail at compile time without the msword8.h and cpp files. Replacing them with the app or doc doesn't work as none of the functions are declared the same, and the prototypes for the classes are missing??? Parameters have changed between versions too.
Can you tell I'm a little frustrated???
Still, if anyone knows how to open a document in an embedded word application, I'd love to hear from you. Preferably using MSWord 2002 or better and Visual Studio 8 aka VS 2005. I'm still searching...
Thanks,
Bravo!!!
P.S. on the outside chance I do come up with a breakthrough, I'll be sure to post it here on codeguru. You guys rock!!!
Re: Need Help embeded word .tlh issue
Quote:
Originally Posted by Bravo
(old vs. current). Where do you turn and what do you do?
1) Reproduce the situation using the old environment if possible.
2) Carefully review the "Whats New" documentation for the "next"
version
3) Implent the solution using the "next" version.
4) Repeat #2, #3 until you are at the current version.
That IS what I do. And typically get well paid for doing it.
Quote:
Can you tell I'm a little frustrated???
Yup...but I never said it was easy... :D
Quote:
Preferably using MSWord 2002 or better and Visual Studio 8 aka VS 2005.
Accessing Office documents has always been a challenge...but that all changed over a year ago...
Use the new OPEN office document formats (e.g. .docx), now you can open them and modify them in a fully supported means using ANY development environment you choose, even without installing the Office Object models on your machine.
If you MUST use the older formats (e.g. .doc), then write a simple wrapper...
1) Open .doc
2) Save As .docx
3) Manipulate .docx
4) Open .docx
5) Save as .doc.
You need only write the wrapper ONCE, and it is fairly straght forward.
Thanks,
Bravo!!![/QUOTE]
Re: Need Help embeded word .tlh issue
I just stumbled over the same issue. Has someone finally found a way to use word automation with VC 8 and Word 2003 without using VC 7 first??