I've programmed an add-in for VS2010, one of the code-lines from this add-in is:
Command command = commands.AddNamedCommand2(
_addInInstance, "MyAddIn", "MyAddIn",
"bladiebla", true, 59, ref contextGUIDS,
(int)vsCommandStatus.vsCommandStatusSupported
+ (int)vsCommandStatus.vsCommandStatusEnabled,
(int)vsCommandStyle.vsCommandStylePictAndText,
vsCommandControlType.vsCommandControlTypeButton);
The number 59 is the code of the icon to use.
Somehow when you use the number 59, a smiley appears as icon. Some testing did show that 47 shows an eraser, and 58 shows a x2-sign.
One question is where those icons come from?
Another question is how to add my own icon.
I tried:
var bitmap = new Bitmap(#"c:\myicon.ico");
and replace the number 59 with the bitmap object (this should be possible because the parameter for that function requests an object. But this did not work.
Look at my bookmarks, these references should be of use to you:
For information about how to find the ID numbers for standard icons, see Listing Button Faces in the Command Bar for the Microsoft Office System on the MSDN Web site.
How to: Change the Default Icon for an Add-In
ref: http://msdn.microsoft.com/en-us/library/ms165626(v=VS.100).aspx
How to: Display a Custom Icon on the Add-In Button
ref: http://msdn.microsoft.com/en-us/library/ms228771.aspx
Related
In an Outlook 2013 VSTO addin (C#), I can check to see if the user is currently in the Calendar area/view by using "if(ActiveExplorer().CurrentView is CalendarView) ..."
How do I do something similar to check and see if the user is in the Mail view, where "Mail" is selected/blue at the bottom of the Outlook window and the user sees their Inbox items? There is no MailView type, or anything similar that I could find, to compare ActiveExplorer().CurrentView, etc., against.
Instead of using the CurrentView property of the Explorer class I'd suggest checking the DefaultItemType property of the Folder class. It returns a constant from the OlItemType enumeration indicating the default Outlook item type contained in the folder.
The CurrentFolder property of the Folder class returns a Folder object that represents the current folder displayed in the explorer. So, the code may look like the following one:
ActiveExplorer().CurrentFolder.DefaultItemType
I have encountered a "quirk" in Outlook 2013 when attempting to have Outlook open a new window for a search (when a button is clicked in my Outlook add-in). The search does not initiate; the search term appears in the box but only the inbox contents are displayed (albeit with highlighting of my search term if relevant to Inbox items). If I then change anything in the search box (e.g. add then remove a quote) it kicks off correctly (i.e. filters the Output to my search).
I cannot reproduce this issue in Outlook 2010, nor if I call the same code via a standalone EXE. Also, it works correctly if I launch the search to an existing Explorer window.
Here is my code (simplified):
OutlookApp := GetActiveOleObject(OUTLOOK_APPLICATION_CLASS);
OLNameSpace := OutlookApp.GetNameSpace(MAPI_NAMESPACE);
OLNameSpace.Logon;
objFolder := OLNameSpace.GetDefaultFolder(olFolderInbox);
objExplorer := OutlookApp.Explorers.Add(objFolder, olFolderDisplayNoNavigation);
objExplorer.Search(sSearchText, olSearchScopeAllFolders);
objExplorer.Activate;
...
While debugging, I have tried:
Changing the display options for the new Explorer window (olFolderDisplayNormal)
Calling ClearSearch before searching
Performing an alternative search beforehand
Even sleeping between calls :-o
I would like to hear of any suggestions for workarounds, or anything I have missed...
Thanks
Resolved by delaying objExplorer.Search() (by creating a new explorer and posting a message to the window, which then enacts objExplorer.Search). Ugly, but works :-(
I have an ActiveX control that installed on my machine, and can be added from PowerPoint via:
Developers->Controls->More Controls->"My control".
I want the user to be able to add the ActiveX via Custom button on the Ribbon.
I successfully added a button to my custom Ribbon (VSTO). but I can't find a way to make this button adding "My Control" to the slide.
I also successfully added an Excel sheet by calling:
Shapes.AddOLEObject(1, 1, 100, 100, "Excel.Sheet", "", MsoTriState.msoFalse, "", 0, "", MsoTriState.msoFalse);
but I can't fint the appropriate way to add my custom ActiveX.
What am I doing wrong?
How can I load this ActiveX from C#?
After two days of searching an answer I found the trick:
the problem is that you need a specific string that recognize the ActiveX control.
what I did is:
open Word and on the developers ribbon record a macro (this option not exists in powerpoint) of mouse clicks
add your control (Controls->More Controls->"My control")
stop recording macro.
view the macro's VBA created (click edit macro) you can find a
string like "myControlLib.myControlctrl.1"
this is the string needed by the Shapes.AddOLEObject(...) as class name.
Microsoft have a utility called OLE/COM Object viewer. You can use it to find the ProgID (the string used to add ActiveX controls in PowerPoint) along with pretty much everything else you'll want to know about your control. Have a look at:
http://msdn.microsoft.com/en-us/library/d0kh9f4c.aspx
I've just built an MS Outlook Add In using Visual Studio and Office 2010. I've installed it ok on 4 machines, but one user is getting the following error -
Error found in Custom UI XML of "...."
...
...
Failed to find Office control by ID
Everyone is running Windows 7 and Outlook 2010 - not sure why this person is having a problem. Can anyone suggest how to diagnose this?
For those having similar issues, you don't have to remove any add-in.
What is happening is: Outlook will try to load all ribbons (found in your ribbon xml) into any window the user goes to. Then it'll complain about not finding ID x or y.
Just make sure your GetCustomUI method in Ribbon.cs does not load the entire ribbon XML at once but rather loads it per fragment.
If you're not sure what IDs you need to target, use a breakpoint in GetCustomUI then start Outlook, surf different views (main, new email, new appointment, calendar...etc) in order to gather the IDs for the views wherein you need to show you add-in.
In my case, I needed Microsoft.Outlook.Explorer, Microsoft.Outlook.Mail.Compose and Microsoft.Outlook.Appointment.
Therefore I changed my GetCustomUI to:
public string GetCustomUI(string ribbonID)
{
switch (ribbonID)
{
case "Microsoft.Outlook.Explorer":
return GetResourceText("MyAddin.RibbonsForOutlookExplorer.xml");
case "Microsoft.Outlook.Mail.Compose":
return GetResourceText("MyAddin.RibbonForOutlookMailCompose.xml");
case "Microsoft.Outlook.Appointment":
return GetResourceText("MyAddin.RibbonForOutlookAppointment.xml");
default:
return null;
}
}
Of course, I had to break down my Ribbon.xml into the three XML files mentioned above. The result: Outlook will ONLY load the fragment needed for a given screen (appointment, new email ...) and will not complain about "not finding an ID on screen X or Y".
Finally, for those who are not sure why some users get that error while others don't: it's because of "Show add-in user interface errors" option (in Options -> Advanced). If that is unchecked then Outlook will ignore the malformed ribbon XML errors. If it checked, users will get related errors about your add-in (if any exists) and also about other add-ins.
If it works for everyone except one user. As #Brijesh Mishra mentioned check if the user has got any other addin and if he is having own quick access tool bar customized.
If he has got any of this then, remove the other addins and try to install or reset the quick access tool bar customization.
For all of you that use a Designer-based VSTO plugin, and not the XML solution.
I searched all the web for this problem, but only found XML-based solutions.
There's nothing for Visual Designer on the web, because in this case you don't have to override the "GetCustomUI" method.
Ribbons designed by using the Visual Designer return a RibbonManager by default.
This RibbonManager object represents all Ribbon (Visual Designer) items in the project and is automatically handled in background through the active window inspector.
So you don't have to write any special code to handle different windows.
To configure it correctly you just have to:
Add one extra Visual Designer Ribbon for every window the user goes to
in the Ribbon Object go under "RibbonType", open the checkbox list an only activate the corresponding window, where the ribbon should appear.
If there is more than one window checked in the list, Outlook trys to insert the ribbon in all the marked windows. Even if the corresponding window is currently not opened. That's the reason, why the error "Failed to find control ID" appears.
the actual fix for me was to separate the ribbon XML files containing the customUI and redirecting to the correct one in the GetCustomUI method (implemented using Office.IRibbonExtensibility)
in example:
public string GetCustomUI(string RibbonID)
{
switch (RibbonID)
{
case "Microsoft.Outlook.Mail.Read":
return GetResourceText("namespace.type1.xml");
case "Microsoft.Outlook.Mail.Compose":
return GetResourceText("namespace.type2.xml");
default:
return null;
}
}
I used the VS 2010 SDK to create and show a custom ToolWindowPane with a WPF control as content. I create a new instance and show it each time a Tool menu item is clicked (the ProvideToolWindow attribute has MultiInstances = true).
When the user attaches the debugger (e.g., hits F5 while in C# project) my ToolWindowPane suddenly hides. I'd like to make sure my tool window is always visible while open, no matter what context the user is in. Is there a way I can enforce that?
I've tried using the ProvideToolWindowVisibility attribute but that automatically shows a new instance of my tool window rather than keeping a remaining one open.
For VS 2010 SDK Microsoft added a new flag __VSCREATETOOLWIN2.CTW_fDocumentLikeTool
You can use this way:
public override void OnToolWindowCreated()
{
IVsWindowFrame windowFrame = Frame as IVsWindowFrame;
object varFlags;
windowFrame.GetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, out varFlags);
int flags = (int)varFlags | (int)__VSCREATETOOLWIN2.CTW_fDocumentLikeTool;
windowFrame.SetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, flags);
}
This way Tool Window persist open at "Document Well" when you go Debugging
However I have to say this give us some problems when debugging projects, avoiding us to open code files while debugging, like if Visual Studio document management was 'block', there are not so much information for this new flag...
So we preferred to hook to EnvDTE.DebuggerEvents and show the ToolWindow if hide when a debugging session start...
(our ToolWindow has MultiInstances = false)
Implement QueryShowTool
public:
int QueryShowTool(Guid % rguidPersistenceSlot, System::UInt32 dwId, [Runtime::InteropServices::Out] int % pfShowTool);
Enables the VSPackage to control whether to show or hide the tool
window. The shell calls this method when the user switches views or
contexts, for example Design, Debugging, Full Screen.
See https://learn.microsoft.com/en-us/visualstudio/extensibility/opening-a-dynamic-tool-window?view=vs-2017