PaulNations

I have an old VB6 program that uses Word automation to fill in a bunch of bookmarks with text from the database. I urgently need to rewrite it, as it only works on a few relic machines now. When I started the conversion I see that the Bookmark.Range object has been deleted from the .NET object model. I'm trying to download the new definition from http://www.microsoft.com/downloads/details.aspx familyid=da039ba4-b7c2-4f99-a45a-0b210299c2b7&displaylang=en

but, it's hung up.

Using Intellisense I note that it's suggesting I replace the Range object with the XMLNode object. Could someone expound on that suggestion, please. I don't know when the object model document will ever be finished downloading.

Thanks.



Re: Visual Studio Tools for Office Converting Interoped Code to Managed Code

Cindy Meister

Hi Paul

You don't give us enough information. Which version of Word is involved, and which .NET programming language

Please note that this forum is targeted specifically at the VSTO technology and not at general Office interop. It's not clear from your problem description whether you're working on a VSTO project or not...

I can tell you that Bookmark.Range does still exist. But if you're trying to use C# then you need to look for a "get_" construct that lets C# pass the parameters via a method.






Re: Visual Studio Tools for Office Converting Interoped Code to Managed Code

PaulNations

Word version is 2007.

VS is 2005.

I'm using VB code. Not C#.

In my project References I have;

Microsoft.Office.Tools.Common

Microsoft.Office.Tools.Common2007

Microsoft.Office.Tools.Word

Microsoft.VisualStudio.Tools.Applications.Runtime

And when I hover over the Range object I get an Intellisense message that Word.Range is not defined and I should change it to Word.XMLNode. I'm okay with changing all of those IF the new XMLNode will function the same as the Range object.

You said the Range object is still in there. What reference do I need to add in order to access it

Thanks.

In the meantime, I've downloaded and installed the Office 2007 Primary Interop Assemblies redistributable package and attempted to reference Microsoft.Office.Interop.Word.dll in my program. Nowhere is it to be found. I searched the entire C drive and still don't find it. How do I reference something that is supposed to be installed when I can't find it anywhere on the machine





Re: Visual Studio Tools for Office Converting Interoped Code to Managed Code

Cindy Meister

So, this is a VSTO 2005 SE Add-in project Or is this a VS 2008 VSTO project I'm double-checking, because you didn't mention that before now, but your list of references includes the "Tools" entries, including Tools.Word which doesn't really make sense.

Did the project create the listed references for you automatically Or did you create the list in an attempt to get things to work

What you're missing is a simple reference to Word. If this is NOT a VSTO project, then you shouldn't have any of the Tools references. Instead, you need to right-click the project name, choose "Add Reference" then go to the COMS tab. From that list (and it will take a while for VS to build it) choose the entry for Microsoft Office Word 12 (or similar).






Re: Visual Studio Tools for Office Converting Interoped Code to Managed Code

PaulNations

It's VSTO 2005 SE. But, its a conversion from the original VB6 program. The conversion created a bunch of references to COM objects and I'm wanting to get away from that if I can. I'm having a lot of problems with keeping a machine that will run the COM relic.

The references to Word & Tools are all added by me in an attempt to find the Range object. I'm now attempting to add the Inerop.Word but I'm having a devil of a time. I see it in the gac but don't find any file that I can point the references to.

I wanted to see what references the project type created so I just tried to create a new Word Document project in VS2005 and get this message:

"Programmatic access to the Microsoft Office Visual Basic for Applications project system could not be enabled. If Microsoft Office Word or Microsoft Office Excel is running, it can prevent programmatic access from being enabled. Exit Word or Excel before opening or creating your project."

The only thing is that I don't have Word or Excel running, I've rebooted and then double checked the Task Manager processes to make sure. But I still get this message.

My workstation is Vista with UAC disabled.





Re: Visual Studio Tools for Office Converting Interoped Code to Managed Code

Cindy Meister

You won't be able to get away from COM references, as the Office apps are still strictly COM (as is Windows). You will, at the very least, have COM references to Word and to Office. These should work through the 2007 PIAs that ought to be in the GAC. You access them through Add References, the COM tab, as I described before. Don't try to link things in in any other way. Referencing the TLB files directly will generate a set of IAs that wouldn't be optimized by Microsoft, wouldn't work well with VSTO and would have to be redistributed as part of your application - in the application folder, not in the GAC. You do not want to do that.

As to the error message: if you start Word are you able to record a macro Open the VBA editor Is VBA installed on the machine and are macros in trusted locations able to run






Re: Visual Studio Tools for Office Converting Interoped Code to Managed Code

PaulNations

I was able to create a macro in Word 2007 and I was able to create VBA in Word 2007.

I'm running this on Vista, so I downloaded and installed the VS2005 SP1 and SP1 for Vista, even though they reported already being installed.

I can't help but think that this access problem is related somehow to Vista. I've had nothing but problems with this new machine since I took it out of the box 4 weeks ago. I'm just about 5 minutes from wiping the drive and installing XP. If that happens Vista will likely not be installed in our building - EVER. As I'm the only person remotely trying to get it to run.





Re: Visual Studio Tools for Office Converting Interoped Code to Managed Code

Cindy Meister

I'm still using Windows XP for production, so I can't comment, really, about whether Vista is the problem. But do you have access to any kind of virtual machine software I'm using VMWare 6.0 workstation on Vista and it runs fine (WinXP in the VM). That would give you a relatively quick way to compare what works and what does not / where the problems may be coming from Vista and where not.

In any case, you should definitely develop and test on a machine with the same software combination as the systems that will be using your solution.






Re: Visual Studio Tools for Office Converting Interoped Code to Managed Code

PaulNations

I have MSDN incident support. I'm now ready to submit an incident and get the engineers involved.

When I open a VS2005 project, any project type and try to add a reference, any reference - VS2005 immediately crashes with a message that it needs to shut down. I've applied every patch and even uninstalled / reinstalled VS2005.

All this stuff is beginning to make truck driving in New Jersey look like a relaxing career change.





Re: Visual Studio Tools for Office Converting Interoped Code to Managed Code

Sue Mosher - Outlook MVP

Are you running VS as administrator