PowerPoint 2007 and 2010 Smart Tag Action Target is Null
-
lundi 9 juillet 2012 16:07
I have an Office COM add-in written in C# for PowerPoint, Excel and Word that uses Smart Tags. The Smart Tags work fine in all supported versions of Excel and Word (2003, 2007, and 2010) but don't work in PowerPoint 2007 or 2010 (PowerPoint 2003 works fine). The issue is that when a Smart Tag action is called the Target parameter is null rather than a valid PowerPoint.TextRange object as in PowerPoint 2003.
I found numerous posts to other forums regarding this issue but no replies to any. So, is this just a pure bug in PowerPoint and is there any workaround?
Toutes les réponses
-
lundi 9 juillet 2012 17:27Currently the add-in code uses the target TextRange to get the PowerPoint application object using PowerPoint.TextRange.Application. If there's another way to get the PowerPoint application object that would be fine since I already have the recognized text in the Text parameter of the InvokeVerb method.
-
mercredi 11 juillet 2012 06:06Modérateur
Hi Drew,
Thanks for posting in the MSDN forum.
I will involve some experts into you issue to see whether they can help you out. There might be some time delay, appreciate for your patience.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
-
mercredi 11 juillet 2012 07:12Modérateur
Drew,
Would you post code snippet in this context?
thanks.
Forrest Guo | MSDN Community Support | Feedback to manager
-
mercredi 11 juillet 2012 15:15
There's not much to the code in question. The class implements the Smart Tag InvokeVerb interface and when it is called from PowerPoint, the target parameter is null.
I need to get the Office application object which is done by casting the target parameter to the approriate range type and then accessing its Application member. That works for Excel and Word, and PowerPoint 2003 but with PowerPoint 2007 and 2010 the target parameter is null.
If there is another way to get the Office application object that would be a good workaround. I do have access to the text recognized by the Smart Tag in the text parameter of InvokeVerb.
[Guid("0231A289-CCA1-4256-A8EC-C0BDDBA4CC2A")] public class Actions : SmartTagLib.ISmartTagAction { ... public void InvokeVerb(int verbID, string applicationName, object target,SmartTagLib.ISmartTagProperties properties, string text, string xml) { if (!InitializeApplication(applicationName, target)) return; ... } private bool InitializeApplication(string appName, object target) { ... if (appName.Contains("Excel")) { Excel.Range range = (Excel.Range)target; // target is valid SmartTagHelper.MOIOffice.Initialize(range.Application, out status); } else if (appName.Contains("PowerPoint")) { PowerPoint.TextRange range = (PowerPoint.TextRange)target; // target is null SmartTagHelper.MOIOffice.Initialize(range.Application, out status); } else if (appName.Contains("Word")) { Word.Range range = (Word.Range)target; // target is valid SmartTagHelper.MOIOffice.Initialize(range.Application, out status); } ... } }- Modifié Drew Lettington mercredi 11 juillet 2012 21:32
-
jeudi 12 juillet 2012 08:53Modérateur
In debug this issue, given you set breakpoint at the line that target is null, this parameter should come from statements that call InvokeVerb or earlier method in callstack. You may track it and check in which line the parameter initialized as null.
Thanks.
Forrest Guo | MSDN Community Support | Feedback to manager
-
jeudi 12 juillet 2012 15:41
InvokeVerb is the Smart Tag callback from Microsoft Office when a term is recognized to implement the Smart Tag action. PowerPoint is passing the null in PowerPoint 2007 and 2010; PowerPoint 2003 passes a valid TextRange object. So the questions are: why did the Microsoft Office behavior change between 2003 and 2007, why does PowerPoint pass null while Excel and Word pass a valid range, and is there a workaround to get the PowerPoint application object?
-
jeudi 12 juillet 2012 16:04Modérateur
I'll try to get other people help on this issue. Please wait some time.
thanks.
Forrest Guo | MSDN Community Support | Feedback to manager
-
jeudi 12 juillet 2012 18:19Modérateur
Hi Drew,
When the Application is PowerPoint consider using code such as
oPPT = Marshal.GetActiveObject(“PowerPoint.Application”);To get a pointer to the application object.
Please remember to mark the replies as answer if they help and unmark them if they provide no help. and click "Vote as Helpful" this and other helpful posts, so other users will see your thread as useful. Best Regards, Chris Jensen
- Proposé comme réponse Forrest GuoMicrosoft Employee, Moderator lundi 16 juillet 2012 01:54
- Marqué comme réponse Forrest GuoMicrosoft Employee, Moderator jeudi 19 juillet 2012 01:29

