office-interop

Reading text format from Excel using Microsoft.Office.Interop.Excel

你离开我真会死。 提交于 2019-12-11 01:11:57
问题 I am trying to read text format e.g. the Strikethough property via myworksheet.Cells[row, col].DisplayFormat.Style.Font.Strikethrough; However, the result is always false, not matter what the actual formatting is. Right before that, I read the value of the same cell using: myworksheet.Cells[row, col].Value; And get the correct value. When I try using the debugger to read myworksheet.Cells[row, col].DisplayFormat.Style.Font.Strikethrough I receive false. When I try using the debugger to read

Powerpoint 2010 Multiple Instances

不问归期 提交于 2019-12-11 00:49:54
问题 I have seen numerous posts on this subject here, but none seem to answer this issue directly. I want to control two instances of Powerpoint running on a second monitor. The ideal solution looks like this: PowerPoint.Application PPTViewer1 = new PowerPoint.Application(); PowerPoint.Application PPTViewer2 = new PowerPoint.Application(); I can do this manually, simply by starting two instances of PowerPoint, loading the presentation, and starting the slide show from each instance. I can toggle

Rotate text only in specific Excel row

浪尽此生 提交于 2019-12-11 00:00:58
问题 I'd like to rotate headers in an Excel file using Microsoft.Office.Interop . To achieve this, I'm using the following code: worksheet.Range["A1:" + worksheet.UsedRange.Columns.Count + "1"].Style.Orientation = Excel.XlOrientation.xlUpwards; The result looks like this: As you can see, every cell gets rotated although I'm only specifying the first row. However, I just want the headers to be rotated: I even tried it with a for loop for every column: for (int counter = 1; counter <= worksheet

Why dsofile.dll still need Office Installation?

邮差的信 提交于 2019-12-10 23:09:26
问题 I wrote a small piece of code using the dsofile.dll component to modify document properties after upload a file to a web server (to set a guid to link the file to a database record). I took the component and intructions from here: http://support.microsoft.com/kb/224351 As far as I understanded it don't use Office to modify the properties. I implemented it and tested it on my 32 and 64 bit machine (webserver runs on 32bit mode) and all worked fine. I was happy. But after deploy it to a life

C# How to access static class List<> from another class

余生长醉 提交于 2019-12-10 22:39:11
问题 Using C#, I have a static class that has a static list of a custom type. Here is the custom type: public class LanguageItem { public Word.WdLanguageID Id { get; set; } public string Name { get; set; } public LanguageItem(string name, int id) { Id = (Word.WdLanguageID)id; Name = name; } } And here is the static class that uses this type: public static class LanguageList { public static List<LanguageItem> _languageList; static LanguageList() { _languageList.Add(new LanguageItem("Arabic", 1025))

Replace bookmarks content without removing the bookmark

流过昼夜 提交于 2019-12-10 22:27:49
问题 I want to replace the text content of bookmarks without loosing the bookmark. foreach(Bookmark b in document.Bookmarks) { b.Range.Text = "newtext"; // text is set in document but bookmark is gone } I tried to set the new Range of the bookmark before the Text setting but I still have the same problem. I also tried to re-add the bookmark with document.Bookmarks.Add(name, range); but I can't create an instance of range. 回答1: I had to readd the bookmarks and save the range temporarily. I also had

Passing a namespace into a function

耗尽温柔 提交于 2019-12-10 21:25:18
问题 I've got a function which takes a word document and saves it in html format. I'd like to use the same function to work with any document type. I've tried using generics (I'm assumming the different doc APIs are the same) which fails due to the reason Jon Skeet pointed out. Is there another way? using Word = Microsoft.Office.Interop.Word; using Excel = Microsoft.Office.Interop.Excel; //Works ok private void convertDocToHtm( string filename ) { ... snip var app = new Word.Application(); var doc

80040154 Class not registered ERROR in Outlook 2010 Add In

末鹿安然 提交于 2019-12-10 21:13:45
问题 I am using Visual Studio 2010 to create a Outlook 2010 Add In. I try to create a new Outlook AppointmentItem to work with thinking that I can add it to the calendar eventually. Microsoft.Office.Interop.Outlook.AppointmentItem tempApp = new Microsoft.Office.Interop.Outlook.AppointmentItem(); But when the AddIn runs and trys to create the AppointmentItem object, I get this error on the line above. System.Runtime.InteropServices.COMException was unhandled by user code Message=Retrieving the COM

How to Add Office Graph in word

你说的曾经没有我的故事 提交于 2019-12-10 19:34:51
问题 Hi every one this is my first question here. I want to add a Office Graph in word 2007 using C# 4.0, I am using Office 2007 word, for better charts like 3D Bubble My task is to Genrate Graph and table from sql database i have done it in good menner with using the excel chart then copy chart as image in word. now i want to add chart itself in word so that the user can change the chart or its value. currently i m doing this code. object missing = Type.Missing; Word.Application application = new

DisposableAction and Marshal.ReleaseComObject

北战南征 提交于 2019-12-10 19:09:57
问题 doing some office Interop and the code is of Type try { selection = getSelected(Return.Some.Office.InteropObject); for ( int i = 0 ; i < selection.count ; i++) yield return selection.item(i) } finally { Marshal.ReleaseComObject(selection); } Wondering if it's a good idea to replace it with a DisposableAction and change to using ( var a = new DisposableAction(getSelected(Return.Some.Office.InteropObject)) ) { foreach(var b in a.Items) yield return b; } 来源: https://stackoverflow.com/questions