We are trying to add some programming to Word 2013 documents. I have VSTO installed. From Visual Studio 2012, I create a Word 2013 project. Since another person has been working on the Word doc in question, I choose to open a copy of it.
When I run my project I always get this message: "This document contains custom code that cannot be loaded because the location is not in your trusted locations list....If you trust this document you can save and open it from a location on your computer."
Well, the document is in a folder named c:\temp. I have gone into the Word 2013 trust center and made this a trusted location. So, not only is the error message wrong, but it is wrong in two ways. (Wrong #1: Not a trusted site. Wrong
#2: From a location on [my] computer.)
Does anyone know how I can create a Word project in Visual Studio 2012 that I can actually open from VS without getting the "trusted location" message? Thanks.
can't open a Word document
How to detect shape selected within a group in PowerPoint C#?
Hi,
I need to detect selected shape within the group for changing properties of it.
The group has many shapes of several "types" by their Name property (e.g. I have 3 types of shape), programmatically generated, so I have to know exactly which shape is selected by user. How can I do it?
For example get an index of Application.ActiveWindow.Selection.ShapeRange[1].GroupItems[index] or some other way to determine selected shape.
P.S. I saw the topic How to detect shape selected within a group in PowerPoint C#/VBA?(can't put the hyperlink), but the answer isn't suitable for me.
Ribbon buttons cannot be actioned by the mouse in Excel 2013
In an Excel VSTO that works perfectly in Excel 2007 and 2010 there is a problem when it is used in Excel 2013.
The ribbon buttons, both in the menu ribbon and on the right-click cell menu become unresponsive to the mouse - although can be actioned using the up and down arrows, or shortcut letter.
It is only the second level down buttons that become inactive: On the right-click menu, I have added a (msoControlPopup) button above the built-in Cut menu button, and I can click on that with the mouse to display the sub-menu buttons, but I can not click on these sub menu items with the mouse.
Initially when I open Excel all the menu buttons work fine, but if I run a process that downloads a lot of data from a webservice using the VSTO the second level buttons stop responding to the mouse. Once the issue occurs, the built in second-level buttons off the Filter and Sort menus also become unresponsive.
This happens on multiple different pcs, 64 & 32 bit and on Windows 7, 8.1 and 10
What has changed in Excel 2013 that means the ribbon buttons become unresponsive?
I have also seen similar unresponsiveness with the standard ribbon to the point where Excel becomes unusable. A search for answers online only seem to suggest disabling all addins but there are no other addins enabled. It also indicates that there must be a common issue with addins and the ribbon buttons.
Any suggestions greatly received.
Checking the value of a PlainTextContentControl
I have created a Word project in Visual Studio 2012. My goal is to have the value of a PlainTextControl conditionally set the appropriate checkbox else on the form. (For example, if the user puts "1" there, the first checkbox gets set, etc.)
I have created Exiting, Entering and ContentUpdating methods in the "cs" file. When I start the project, I enter a value in the PlainTextControl in question. In all three methods, I wish to inspect the value that I've set. However, I am not seeing what I entered. For example, if I put a "7" in the PlainTextControl, I am seeing this:
plainTextContentControl25.Text = "[]"
I have tried to access the Range property, the Cells property and the Characters property. I have yet to see a "7" as the property of the control's text anywhere.
How do I inspect the text the user entered into a PlainTextContentControl while in one of its methods?
VSTO Ribbon DropDown Item Limit
There was question asked before on this topic:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/8a1738da-f014-4029-a999-40b6d100cd70/ribbondropdown-ribboncombobox-ribbongalery-maximum-items?forum=vsto
I'm not an experienced VSTO Developer so I just need clarification - is it saying the limit is absolute? If not can someone shed a little more light on how I can change it?
Thanks!
SPD
how to set an existing checkbox to true or false
Hello,
How do I programmically set an existing checkbox in a Visual Studio 2012 Word 2013 project? I have been studying some other examples. (Note: I am forbidden from linking to the other examples because my account is not verified.)
...However, I am not creating a new checkbox. The document is in Word 2013 format. Also, the checkbox in question is a plainTextContentControl. I wish to set the checkbox in a method for another plainTextContentControl. Something like this:
private void plainTextContentControl125_Exiting(object sender, ContentControlExitingEventArgs e)
{
plainTextContentControl10.Checked = true;
}
However, I don't see anything as easy as a "Checked" property on the checkbox I wish to set.
Does anyone have an idea how to do this? Thanks.
Security Update for Microsoft Excel 2013 (KB3085502) 32-Bit Edition causing issues in Excel
Hello,
Just wanted to let know after installing this update - using Excel Add-in become unworkable because of graphics issues. How this happens: My clients using few functions in Excel Add-in, after they close and open another workbook Excel starting to do crazy things with graphics, just trying to scroll or select 2 columns all columns and rows mess-up, also we can't edit cells because what ever you write and press enter nothing changes, Closing Add-in helps for a few moments. Already on 6 clients PC this happened - Uninstalling this (KB3085502) update resolves problem. Here are images:
First how it is in normal state.
After i try to Scroll with mouse and Select 2 columns(H,I):
Here is an update which cause all these problems.
September 2015 Office Update Release:
Excel Automation through windows service written in C# fails in Office 365 installed machines
I am working with Windows Service written in C#. Through this windows service I am automating Excel in programmatic way.
Excel.Application excel =Excel.Application();
This code was working fine with all versions of Excel (2003,2007,2010,2013). Recently I have installed Office 365 in my machine. Suddenly I am getting below exception when I automate the Excel using above call.
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
Can anyone let me know, is there any special consideration should be taken when automate the Office 365 Excel via Windows Service
VSTO Using Ctype
hi guys
i am new to vsto and trying to convert my existing vba code to vsto code. there is something confusing me. Why shouls we use Ctype to convert a range object to Excel.Range even if range itself returns a range rather than object type.
the code ise below. if i dont use Ctype, it gives error(option strcit doesnt allow late binding)
CType(app.Columns("A:A"), Excel.Range)
Dig your well before you are thirsty
how to show hidden bookmarks?
Does anyone know how to either set the Showhidden property or otherwise see the hidden bookmarks?
Events for a plainTextContentControl in a table
In the Word document I am developing VSTO code for, we have a table with three columns. In the left-most column there is a plainTextContentControl (PTCC). I have successfully added events for this PTCC. For example, when I run the project
and click into the PTCC and then tab away, it fires off the exiting event.
The table (which contains the PTCC) has to allow the user to add more rows during runtime. Unfortunately, when I add additional rows at runtime, I can't get the PTCC events to run except for the first one that is there.
Does anyone have a suggestion about how to make sure that if the user adds rows at runtime the events for the new PTCC can be triggered (just like the initial row)?
Thanks in advance.
Reading Data from excel
I have a WPF application, where I have a functionality to read data from excel.
I was doing this using OLEDB and it was working great, until I found out there was a 255 limit for columns and the data would be truncated unless data > 255 characters is not present in the first 8 rows. Fix for this issue is to update the registry which
would mean to update all users registry. So I don't want to go with that approach.
OLEDB code:
string strSQL = "SELECT * FROM [Sheet1$]";
OleDbCommand cmd = new OleDbCommand(strSQL, conn);
DataSet ds1 = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(ds1);
As an alternative, I tried Interop.Excel . However, it seems to be slower that OLEDB. The excel sheets that was taking 2 secs to
load take about 15 sec to load using Interop.Excel.
System.Data.DataTable tempTable = new System.Data.DataTable();
tempTable.TableName = "ResultData";
Excel.Application app = new Excel.Application();
Excel.Workbook book = null;
Excel.Range range = null;
try
{
app.Visible = false;
app.ScreenUpdating = false;
app.DisplayAlerts = false;
book = app.Workbooks.Open(inputFilePath, Missing.Value, Missing.Value, Missing.Value
, Missing.Value, Missing.Value, Missing.Value, Missing.Value
, Missing.Value, Missing.Value, Missing.Value, Missing.Value
, Missing.Value, Missing.Value, Missing.Value);
foreach (Excel.Worksheet sheet in book.Worksheets)
{
Logger.LogException("Values for Sheet " + sheet.Index, System.Reflection.MethodBase.GetCurrentMethod().ToString());
// get a range to work with
range = sheet.get_Range("A1", Missing.Value);
// get the end of values to the right (will stop at the first empty cell)
range = range.get_End(Excel.XlDirection.xlToRight);
// get the end of values toward the bottom, looking in the last column (will stop at first empty cell)
range = range.get_End(Excel.XlDirection.xlDown);
// get the address of the bottom, right cell
string downAddress = range.get_Address(
false, false, Excel.XlReferenceStyle.xlA1,
Type.Missing, Type.Missing);
// Get the range, then values from a1
range = sheet.get_Range("A1", downAddress);
object[,] values = (object[,])range.Value2;
//Get the Column Names
for (int k = 0; k < values.GetLength(1); )
{
tempTable.Columns.Add(Convert.ToString(values[1, ++k]).Trim());
}
for (int i = 2; i <= values.GetLength(0); i++)//first row contains the column names, so start from the next row.
{
System.Data.DataRow dr = tempTable.NewRow();
for (int j = 1; j <= values.GetLength(1); j++)//columns
{
dr[j - 1] = values[i, j];
}
tempTable.Rows.Add(dr);
}
}
Are there other alternatives that I can use which is as fast as OLEDB? The columns and rows are not fixed in the excel sheet.
VSTO deployment issue
Hi team,
We are developing a VSTO add-in using Visual Studio Professional 2013. We are facing problems while deploying the add-in on user machines using ClickOnce deployment technology.
This was circulated to a group of people for installation, whichworked fine for about 50-60% of cases while generated thefollowing error for others (irrespective of 32 bit or 64 bit windows):
“The value of the property 'type' cannot be parsed. The error is: Could not load file or assembly 'Microsoft.Office.BusinessApplications.Fba, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependancies. The system cannot find the file specified. (C:\Program Files (x86)\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe.Config line 10)”
After some research on the matter we found that the issue is related to‘VSTOInstaller’.The ‘VSTOInstaller.config’ ispart of standard installations of Microsoft product. However, insome cases the ‘VSTOInstaller.exe.config’ takes preference over installer and points at someother files in the GAC
for config and if those files are not present, we get the issue.
Solutions that we found on the internet suggests to either rename the‘VSTOInstaller.config’ files or delete them before installation. However, as we are not sure about thepossible impact of this workaround, this is not adopted.
This seems to be a known issue, please follow the thread with no known solution:
Please suggest a solution to this issue so that we can use ‘clickonce’ for our add-in deployment.
Regards,
Aditya
BDD ans VSTO with Specflow
Hi fellas!
I am currently in the making of an Office 2010 AddIn (specifically for Word 2010). The AddIn is hooking into form generation via a third party templating that calls my C# code.. The AddIn then is ersponsible for addin correct logos etc.
What I want to do is create a test environment and suite to see if my implementation works, based on known values. Problem is, I sometimes need to interact with the forms when they are being generated.
Has anyone used BDD (with tools like specflow) with VSTO Plugins? Is it possible to make user interaction with the Word UI automated? Is it possible to use some kind of event system with VSTO (e.g. I would like to fire an event at the end of my VSTO addin code and pick up that event in one of my BDD scenario steps)?
I hope I could make a bit clear what I try to achieve. The problems root is that I have many different forms that need to be setup correctly but I don't want to test each one individually after implementing a few lines of code.
Cheers Sebastian
Ribbon Attachment Bug in Outlook 2016
Hey there,
I've got a question related to ribbon changes in Outlook 2016. In Outlook 2010 & 2013, when extending the right-click menu for email attachments (ContextMenuAttachments),in the callback handler, the control.Context property was set to a Selection object, which provided direct access to the selected attachment (with class = OlObjectClass.olAttachmentSelection).
Now, in Outlook 2016 preview (where the attachment menu is kind of rebuild - see below), this does not work anymore. Instead of providing a selection object, the context is set to the current Explorer object, which is not helpful at all. Are there any plans to fix this? This is breaking our addins because we now cannot determine the selected attachment anymore, which defeats the purpose of having a custom ribbon there at all. Or is there a new way to determine the clicked attachment?
Thanks!
Adding a form or control on MS Word application from an Add-in
Is it possible to add a control or a form that acts the way the ruler acts on MS word from an Add-In ( visual studio Add-In project)? If this is not clear, think of simulating the ruler itself by designing it on a visual studio Add-In project.
Thank you.
Adding a form or control on MS Word application from an Add-in
Is it possible to add a control or a form that acts the way the ruler acts on MS word from an Add-In ( visual studio Add-In project)? If this is not clear, think of simulating/redesigning the ruler itself by designing it on a visual studio Add-In project.
Thank you.
ASP.NET and Word
I need some design guidance. I currently have an asp.net application that has some word documents that are used as templates and are stored in xml wordml format. I use standard XML processing to replace various parts of the document then send the processed XML document out in the response stream. This works great if the user has Word 2003 installed but now have to find a solution to support other versions of Word, etc. I began to think I could simply keep most of the processing the same (processing a WordML document) but instead of sending the WordML format document to the client have the document first converted to a standard word doc on the server then send to the client.
I thought this may help me get around the incompatibilities with different client versions. But I am having a very difficult time finding similar solutions online. I thought I could use the ServerDocument object to open my WordML file stream but I get an error as soon as I try to initialize the ServerDocument with this file. Here are the steps I am taking:
1. Create an XML document and load it with the WordML document
2. Process this XML document to replace various parts of the document
3. Save the XMLDocument to a MemoryStream
4. Create a new ServerDocument object that takes the memorystream as the first parameter and a filename
5. Send the ServerDocument.Document to the response
the above steps generate an error at step 4 indicating the input stream is either empty, too long or not valid. I have no problem opening the exact same file with the prior approach where the XmlDocument was simply sent to the client as-is and opened locally within Word. So I know the WordML document is valid.
Is this even the right approach I should be attempting? I am finding limited guidance on this subject. The final result is that I need to be able to have "template" word documents on my web server that are dynamically merged with application data and sent to the client as a finished Word document. This needs to be supported in multiple versions of Word as well as Mac clients.
I greatly appreciate any guidance.
Debug VSTO without having to install every time
I am developing an application-level ribbon extension for Excel 2007 using VS2010 and VSTO. I am able to debug the code, but my problem is, every time I make a change to the code I need to uninstall/reinstall the extension (I have a Setup project as well). Otherwise, the extension does not show up in the Excel UI. Is there any way to debug updated code without having to reinstall the extension?
Thanks for any help.
How to enable Office Mail add-in in Microsoft Outlook App in ios
Hi ,
I am trying to create an Mail add-in using visual studio. I want to make it available in the Microsoft Outlook App in ios. Can anyone let me know how to get it done? I am able to get the add-in in OWA
in ios but not the Microsoft Outlook App.
Regards,
Anil