I'm developing a VSTO add-in for Outlook and I would like to add a custom "Send" button that appears somewhere inside the area I've circled in red. Is this possible? And if so, how? I believe SalesForce has something like this in their add-in.
Add custom Send button to Outlook New Email window
Outlook Add-in: export a contact to a .vcf file
Error: The project cannot be created. (Excel 2016 VSTO Workbook)
I am trying to create my first Excel 2016 VSTO Workbook.
Setup: Windows 10 (64 bit); Office 2016 (64 bit); VS 2015 Update 3 Community
I can run an Excel 2016 VSTO add-in
I cannot create the template project.
I get the (uninformative) error in the title.
I have trapped the following as the source in the Windows EVENT Viewer:
------------
Faulting application name: EXCEL.EXE, version: 16.0.7369.2038, time stamp: 0x57f8d4b9Faulting module name: VSTOExcelAdaptor.dll, version: 14.0.23928.0, time stamp: 0x56f88e40
Exception code: 0xc0000005
Fault offset: 0x0000000000026df7
Faulting process id: 0x2f14
Faulting application start time: 0x01d22fd856dc246f
Faulting application path: C:\Program Files\Microsoft Office\Root\Office16\EXCEL.EXE
Faulting module path: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Visual Studio Tools for Office\x64\VSTOExcelAdaptor.dll
Report Id: dfc1f022-4a20-46ea-a98b-804f3ceb9d2f
Faulting package full name:
Faulting package-relative application ID:
-------------------
Unable to cast COM object of type 'System.__ComObject' to interface type 'System.Runtime.InteropServices.ComTypes.IConnectionPointContainer'
After checking that an item is of type Outlook.Mailitem, when it is assigned to another variable declared as Outlook.Mailitem WithEvents, the following error is thrown:
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'System.Runtime.InteropServices.ComTypes.IConnectionPointContainer'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B196B284-BAB4-101A-B69C-00AA00341D07}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))
Is there some way to fix this error?
Public
WithEvents oMailItem As Outlook.MailItem
Dim oSelection As Microsoft.Office.Interop.Outlook.Selection = oExplorer.Selection
If TypeOf oSelection.Item(1) Is Microsoft.Office.Interop.Outlook.MailItem Then
Me.oMailItem = oSelection.Item(1)
End If
I am using VS 2010 and Office 2010. The add-in is targeting framework 4.
Ajay Agrawal
Unable to cast COM object of type 'System.__ComObject' to interface type 'System.Runtime.InteropServices.ComTypes.IConnectionPointContainer'
Hello,
According to Cor Ligthert advice I am creating new question regarding my VSTO addin Outlook problem.
I'm creating add-in (Outlook 2010, Win 10 Prof) which will be check outlook item on selection change, and in case of Mailtem (and some other contintions) will add event to this mailitem to capture "Send" button click. Part of my code below:
void explorer_SelectionChange()
{
try
{
if (this.Application.ActiveExplorer().Selection.Count > 0)
{
Object selObject = this.Application.ActiveExplorer().Selection[1];
if (selObject is Outlook.MailItem)
{
Outlook.MailItem mailItem =
(selObject as Outlook.MailItem).........................
Everything works fine with no error, but when I select in my Outlook profile "Public Folders" and then I will try to open some outlook items then I have received an error:
System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'System.Runtime.InteropServices.ComTypes.IConnectionPointContainer'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B196B284-BAB4-101A-B69C-00AA00341D07}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)
The same problem was describe in below question but there no answer on it:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/fb11f14b-4565-4e24-85cb-b53e97e85367/unable-to-cast-com-object-of-type-systemcomobject-to-interface-type?forum=vsto
After setting up breakpoints in code it looks like during reading of the same item (only with Public Folder Outlook view) my addin cannot read some attributiesfor Mailitem, returning for many of them (not all - can read mailitem.Subject for example) error:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in MyOutlookProject.DLL
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
The problem is reproduced on more the one machine.
Can you help what's going on?
Thanks in advice
iziz1
How to get the animations/effect count for each slide in powerpoint?
Im using Microsoft.office.iterop.powerpoint
Well I dont seem to find a method that return the count of animations for each slides..
Or im not sur if its called also effects.
Replace smart (curly) quotes with straight quotes
Thanks to your help. I have developed VSTO addin for my users that performs small changes like remove empty spaces etc.
Now i need to add new functionality. like
Find ‘ (smart apostrophe), replace ' (dumb apostrophe) and find “ (smart quotes), replace " (dumb quotes).
I can't find the documentation on how to do it in c# with Word.Range or Word.Application.ActiveDocument
Can anyone point me in the right direction?
Thank you.
Error when building an office customizatioin
Hi
I do not succeed in developing an office (Word 2010) customization that calls code from VBA, with Visual Studio 2012. I executed walk through "Calling Code from VBA in a Visual Basic Project" but I consistently get the error "Cannot update WIN32 resources in assembly "obj\Debug\<name>.dll". The system cannot find the file specified."
Trust center settings are set correctly.
Thanks for providing help
Build Error: Cannot update WIN32 resources in assembly
I have built a simple Excel 2013 workbook project (not addin) using VS2013 Update 3.
Whenever I set the workbook property "EnableVBACallers" to true (which also automatically sets property "ReferenceAssemblyFromVBAProject" to true) and build the project I get the error "Cannot update WIN32 resources in assembly "obj\Debug\ExcelWorkbook4.dll". The system cannot find the file specified".
The assembly exists and I have trusted the file location from within Excel. When the above properties are set to false, the project builds with no errors.
Any suggestions will be greatly appreciated.
Simulate a click on "Skype Meeting" in Outlook
Hello,
I'm trying write an Outlook plugin that will simulate a click on "Skype Meeting" button in Outlook 2016
I was trying to use Inspector.CommandBars.ExecuteMso("OnUCExplorerOnActionO14"); but no luck
Any idea how to invoke a button in Outlook ?
Excel Document Level Customization - Errors with VBA Interop
I'm following Microsoft articles to build an Excel Document Level Customization
References:
I'm having issues with calling document-level VB.NET code from VBA. I believe the issue is more specific to "ReferenceAssemblyFromVBAProject".
When you set EnableVbaCallers = TRUE, VSTO automagically setsReferenceAssemblyFromVBAProject to TRUE, and adds VBA code to workbook (or sheet):
Property Get CallVSTOAssembly() As TestInterop.Sheet1Set CallVSTOAssembly = GetManagedClass(Me) End Property
On the VSTO side, this code is added to the public class:
<Microsoft.VisualBasic.ComClassAttribute()> <System.Runtime.InteropServices.ComVisibleAttribute(True)>
The problem is, when I try to debug or publish I get the following error:
"Cannot update WIN32 resources in assembly "obj\Debug\xxxx.dll". The system cannot find the file specified
(Where xxx is my project name).
If I set setsReferenceAssemblyFromVBAProject = FALSE, the program will launch, but immediately to a VBA error highlighting the CallVSTOAssembly function with the error:
Compile Error - User defined type not defined.
So I'm sort of in an error death spiral. I believe if setsReferenceAssemblyFromVBAProject = TRUE, then I wouldn't get the VBA compile error. But, I'm unable to avoid the .DLL error. Can someone help with this?
Overall, it seems this approach to customizing is nearly deprecated in favor of Office Apps, but I'd still like to know where I'm going wrong. I'm also using VSTO 2013 and Excel 2013.
Thanks
Binding excel data to a text box control
In my VSTO Excel Document level customisation, I wish to show a textbox in the Actions pane that automatically reflects the current value of a cell (namedrange) in the workbook. Similarly if the textbox value is updated I wish that same cell to be automatically updated with the value. I would like to use a two way Simple DataBinding to achieve this as I plan to generalise this across a number of different controls on the Actions Pane (which my reading so far suggests is do-able). However, I have been unsuccessful(!) and would be grateful for some direction. This is where I have got to:
I have a Windows Form ("apcYADashboard") with a textbox control on it ("tbxFrom"). I have a Worksheet ("Sheet2") in my Workbook with a named range defined in it ("FromDate"). I have added a BindingSource control ("Sheet2BindingSource") to act as the bridge to connect to the object Sheet2 as the datasource object.
I am looking to Bind the text property "tbxFrom" to the value of "FromDate". Here is my code which compiles without error but fails with an exception on oDS.Datamember = "FromDate" advising the Datamember property "FromDate" cannot be found on the data source.
Private Sub ThisWorkbook_Startup(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Me.Startup Dim oYADashboard As New apcYADashboard 'A windows form containing a textbox (tbxFrom) Dim oFromDateBinding As Binding 'A Binding object Dim oDS As BindingSource 'A Binding source to use as a bridge to the named range ("FromDate") on Sheet2 oDS = oYADashboard.Sheet2BindingSource 'The datasource object oDS.DataMember = "FromDate" 'The datasource member oFromDateBinding = New Binding("Text", oDS, "FromDate") 'The binding between the target and the source oYADashboard.tbxFrom.DataBindings.Add(oFromDateBinding) 'Add the binding Globals.ThisWorkbook.ActionsPane.Controls.Add(oYADashboard) 'Add the form to the action pane to display it. End Sub
Programatically setting different rooms across a recurring meeting
Hi,
As we all know, when you create a recurring meeting, and assign it a room, on save, it checks for conflicts an returns an email with the conflicting instances, from where you need to go and manually fix each instance.
Ive got some code that goes through the newly created recurring meeting, and i try to set each instance with a room resource i know is valid and availabile, but two problems occur here: 1. if the AppointmentItem object doesnt have a room resource set at the top level, on save it says that i need to set a room. So, i set a room, then i still go through each recurring meeting instance and set the location on each one. When i save it, it doesnt seem to take this into account and i still get the conflict emails because it is still checking every recurring instance against the top level appoinment room entered.
Any help appreciated!
Can not create project for excel
I tried several times to create a project for excel 2016 VSTO workbook with Visual Studio 2015 Enterprise, but it kept saying “Programmatic access to the Microsoft Office Visual Basic for Applications project system could not be enabled. If Microsoft Office Word or Microsoft Excel is running, it can prevent programmatic access from being enabled. Exit Word or Excel before opening or creating your project.”
After doing some research, I have clicked the "trust access to the VBA project object model and "enable all macros". I've also checked that the visual studio tool is active in add-ins. However, the project still can not be created, and the notification now turns into "The project cannot be created."
What should I do to solve this problem? My office version is 2016 professional, and my visual studio version is 2015 enterprise.
Thanks,
Troy
VS for Azure SQL
I'm about to subscribe to an Azure SQL database.
I've used an on-premise MS SQL Server for many years for tables linked to a MS Access "front end" to develop user interfaces. The users (all on my LAN) also used MS Access as the user interface using a .MDA version of the user interface.
I'm looking for recommendations for a more current way to do this in the cloud as my new business model will have 100's of users around the world.
I can handle the DB design in the Azure SQL but I want something to develop the user interfaces (different for as many as 25 user roles) that won't require me to write code. Within Access I've been able to mostly avoid that (except for a little VBA occasionally).
So is VS the product for me?
Thanks in advance
Not able to debug VSTO Addin Excel 2016 in VS 2015 professional
My last VSTO project was with Excel 2007 and office 2010. I remembered I always be able
to put a break within ThisAddin_Startup(..) function. With vs 2015 and VSTO for Excel 2016
it did not break. Am I missing anything here. Please help.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; using Excel = Microsoft.Office.Interop.Excel; using Office = Microsoft.Office.Core; using Microsoft.Office.Tools.Excel; using System.Windows.Forms; namespace Tanker_Optimizer { public partial class ThisAddIn { private void ThisAddIn_Startup(object sender, System.EventArgs e) { int x; int y; x = 5; y = x; MessageBox.Show(y.ToString()); } private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { } #region VSTO generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisAddIn_Startup); Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } #endregion } }
Outlook display all folders expect Default folders
Hi All
I got a doubt, is there a way to know if a folder is a default folder like olFolderCalendar, olFolderSentMail, olFolderDrafts.
The reason is because I want to display a list of the folder EXPECT the ones that are the default ones.
Im able to get all the folders from the sessions on outlook by doing something like
For Each oStore In objApp.Session.Stores
oRoot = oStore.GetRootFolder
ShowTotalInFolders(oRoot)
Next
ShowTotalInFolders is a sub like
Public Sub ShowTotalInFolders(Root As Outlook.Folder)If Root.Folders.Count > 0 Then
Dim allFolders As Outlook.Folders = Root.Folders
Dim i As Integer = 0
Dim subFolder As Outlook.MAPIFolder = allFolders.GetFirst()
While i < allFolders.Count
list.Add(subFolder.FolderPath.ToString()) <-- here I want to get only the NON default, Maybe just the inbox, + other the users might have created.
subFolder = allFolders.GetNext()
i += 1
End While
End If
I have google for more than 8 hours and not beign able to hit the right path , I dont want to do an if subfolder.Name = "Delete Items" because I want it to be multi language, you know folder names changes between
languages, so I want to have the code as simple/clean as possible. Thank you all.
Microsoft.Office.Interop.Word
Customization of RibbonGroup in Word Addin(VSTO)
Hello Team,
I am looking for the way to simpler customization(RibbonGroup with one dropdown) with spaces around it.
One the built is not allowing me to have margin around the dropdown in group.
Please suggest
C# serialize / de-serialize to/from excel sheet
Hello,
I would like to serialize/deserialize objects directly to/from Excel sheets, in C#.
I want to do so with very little user interaction, only with simple actions like:
- setting some properties of an object
- adding some object into the map (using a custom Ribbon menu)
Long ago (year 2000) I did something similar (in J++),
using a simplified property path syntax and relying heavily on Reflection.
Today, I would like to avoid re-inventing any wheel. (like creating dedicated syntax and using reflection)
Also, I don't see how the xml tools shipped with Excel could help.
That's because -as I understand- it is only possible to map xml files to Excel tables.
I would prefer to edit an object tree directly in Excel.
The depth of the object tree I need would not exceed 3 or 4, but that already to much to handle with tables.
Honestly, an XML editor working on an Excel sheet would almost do the job.
It would just need to be a little more user-friendly.
Something similar to a tree view would be quite helpful.
Would you have so suggestions?
Thanks,
Michel