office-interop

Create Object and its Properties at Run-time from List

℡╲_俬逩灬. 提交于 2020-01-24 09:04:51
问题 I need to create dynamic object and its properties at run-time then create instance of this object to store values. why I want above logic! I am reading excel file in C# and first line of code is header which is actually properties and followed by each rows are record which is instance of dynamic object. List<string> ExcelDataHeader = new List<string>(); for (int y = 2; y <= colCount; y++) { ExcelDataHeader.Add(xlRange.Cells[headerRow, y].Value2.ToString()); } dynamic MyDynamic = new System

How can I read excel custom document property using c# excel interop

ε祈祈猫儿з 提交于 2020-01-22 03:42:06
问题 I'm trying to check if a custom document property has been set for an excel file or not. And if set then read the value. Here is the code I'm using but so far no luck. It doesn't get into the foreach loop and comes out. var propval = ReadDocumentProperty("TestProp"); private string ReadDocumentProperty(string propertyName) { Office.DocumentProperties properties; Excel.Workbook Wb = Globals.ThisAddIn.Application.ActiveWorkbook; properties = (Office.DocumentProperties)Wb

Matlab Actxserver :How could I terminate process opened by actxserver in matlab

痞子三分冷 提交于 2020-01-21 05:54:00
问题 I want to open and close an Excel file in MATLAB. I have tried the code below, but it failed on closing process with actxserver h.WorkBooks.Item(wbkname).Close; here is my code for this issue, how can I terminate the excel file? .Quit .delete I also tried to close excel file via VBA sub-module, but it gives me an error message: fullFileName = [pwd '\KOSPI200_1월.xlsm']; excel = actxserver('Excel.Application'); file = excel.Workbooks.Open(fullFileName); excel.Run('jongho_bot_initial'); excel

Trying to do Office Automation with Excel 2007, but keeps using Excel 2003

安稳与你 提交于 2020-01-20 02:43:36
问题 Environment: Windows XP machine Both Excel 2007 and Excel 2003 installed (in that order, not chronologically). C# 3.5 Problem: When I use the PIAs to do some Office automation, I use the following line of code: var excel = new ApplicationClass(); The PIA's version specifically refers to it as Excel 12. C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll But: excel.Version;//this is 11.0 instead of 12.0 Thus, when I try to open a

Trying to do Office Automation with Excel 2007, but keeps using Excel 2003

拟墨画扇 提交于 2020-01-20 02:43:05
问题 Environment: Windows XP machine Both Excel 2007 and Excel 2003 installed (in that order, not chronologically). C# 3.5 Problem: When I use the PIAs to do some Office automation, I use the following line of code: var excel = new ApplicationClass(); The PIA's version specifically refers to it as Excel 12. C:\WINDOWS\assembly\GAC\Microsoft.Office.Interop.Excel\12.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll But: excel.Version;//this is 11.0 instead of 12.0 Thus, when I try to open a

Excel VSTO chart.mouseup event not firing

喜你入骨 提交于 2020-01-17 10:19:09
问题 I am creating an application level addin for Excel using Excel Interop. Here is my setup: Dim NativeSheet as Worksheet = Globals.ThisAddIn.Application.ActiveSheet Dim vstoSheet as Worksheet = Globals.Factory.GetVstoObject(NativeSheet) Dim vstoChart as Chart = vstoSheet.Controls.AddChart(left:=50, top:=50, width:=50, height:=50, name:="Membrane") I then add three event handlers: for MouseDown, MouseMove and MouseUp. Private Sub _vstoChart_MouseUp(Button As Integer, Shift As Integer, x As

Smartart nodes being added incorrectly in excel worksheet with interop-excel in c#

北战南征 提交于 2020-01-16 14:27:05
问题 I have a c# console application which creates an excel worksheet containing of a smartart object with the hiearchy layout (org chart). When i proceed to add nodes to the smartart object, it places the nodes in incorrect levels. The first node created is called "node 1" and is correctly placed at the first level. I then create 4 new nodes(node 1.1, node 1.2, node 1.3, node 1.4) from the first node to be placed at the second level with node 1 as a parent node. I also created a third level node

Using CustomTaskPane.Window to distinguish between panes

时光总嘲笑我的痴心妄想 提交于 2020-01-16 09:34:06
问题 C# Add-In for Excel. I want to use the CustomTaskPane.Window property in order to know if a pane belongs to the active Workbook. This is my code: var activeWnd = Globals.ThisAddIn.Application.ActiveWindow; var pane = this.CustomTaskPanes.Add(myUSerCtrl, "title", activeWnd); IntPtr panePtr = Marshal.GetIUnknownForObject(pane.Window); IntPtr activeWndPtr= Marshal.GetIUnknownForObject(activeWnd); bool sameWindows = panePtr.Equals(activeWndPtr); When I inspect sameWindows it is false . And the

ASP .NET / VB .net Using Microsoft Interop Word - CreateObject(“Word.Application”) Crash

我是研究僧i 提交于 2020-01-16 09:14:09
问题 I'm just trying to fill a word dot file (using bookmark) with my asp net vb net webform site using Microsoft Interop Word. It works perfectly in debug on my IIS Express, but crash on my Windows Server 2016 / IIS 10. Dim oWord As Word.Application oWord = CreateObject("Word.Application") Server crash with message like this : Cannot create ActiveX component. (original error message : Impossible de créer le composant ActiveX.) I was searching for a fix, but a lot of post about this error are old.

ASP .NET / VB .net Using Microsoft Interop Word - CreateObject(“Word.Application”) Crash

青春壹個敷衍的年華 提交于 2020-01-16 09:13:13
问题 I'm just trying to fill a word dot file (using bookmark) with my asp net vb net webform site using Microsoft Interop Word. It works perfectly in debug on my IIS Express, but crash on my Windows Server 2016 / IIS 10. Dim oWord As Word.Application oWord = CreateObject("Word.Application") Server crash with message like this : Cannot create ActiveX component. (original error message : Impossible de créer le composant ActiveX.) I was searching for a fix, but a lot of post about this error are old.