开发者

Where is where is microsoft.office.tools.word.factory?

开发者 https://www.devze.com 2023-02-21 17:39 出处:网络
I\'m in VS2010, in a new Word Add-In project. This is my first attempt at Word development using VSTO. The example I\'m trying has this line:

I'm in VS2010, in a new Word Add-In project. This is my first attempt at Word development using VSTO. The example I'm trying has this line:

Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);

But when I add this line Visual Studio开发者_如何学Go says it can't find "Factory". Indeed, it's not in Intellisense.

I've got references to:

Accessibility

Microsoft.Office.Interop.Word

Microsoft.Office.Tools.Common.v9.0

Microsoft.Office.Tools.v9.0

Microsoft.Office.Tools.Word.v9.0

Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0

Office

and all the usual System references.

Where am I going wrong and why can't I get to "Factory"? stdole


That example looks a bit weird to me. Never seen that sort of reference before.

Generally, with Vsto, you hook into EVENTS on, say, the main Word App object.

Then, from within the event, you usually are passed a reference to the particular DOC object that the event is occurring for (say, being opened or saved, etc). In that way, there shouldn't be any need for using the "globals" object or the "factory" object, whereever they might be.

What method is that code in? A little more context might help.


I think the recommended way of doing this is:

Globals.ThisAddin.Application.ActiveDocument
0

精彩评论

暂无评论...
验证码 换一张
取 消