office-interop

Access excel cell by its name

℡╲_俬逩灬. 提交于 2019-11-28 08:26:10
问题 I'm trying to set excel's cell name to some custom name and to later access that cell by its name. Is there some out of the box API call to do this, or how should I do this if I have information of worksheet and cell name in case of accessing cell and worksheet and cell address (i.e. C2) in case of naming the cell. Also to ask, is there a way to acquire formatting information that is bound to that specific cell? (i.e. When I'm accessing cell by name I want to return cell value and some

How to disable popups when opening a file using Microsoft.Office.Interop

↘锁芯ラ 提交于 2019-11-28 08:21:44
Such as read-only confirm, other alerts. What to do with these popups? Or ignore them? dotNetkow See my answer here. Basically, you disable all alerts via the "Display Alerts" method: Microsoft.Office.Interop.[OFFICE_APP].Application app = new Microsoft.Office.Interop.[OFFICE_APP].Application(); app.DisplayAlerts = false; where [OFFICE_APP] is the name of the Office program you're using, such as Word, Excel, etc. Uriel Fernandez Here is another alternative to prevent the Security message asking you to allow macros. I read this article from MSDN and figured out the following code: Application

Creating and managing custom task panes for multiple documents in a VSTO Word addin

前提是你 提交于 2019-11-28 07:44:22
I'm developing a Word 2007-2010 addin using VSTO in Visual Studio 2008. In my addin, I need a custom task pane for each open word document. Basically, I need to create a task pane for each document, show the correct task pane in the document window, do something on document close and then remove the task pane and all references to it. This is what I have done so far: Task pane creation I create a custom task pane for each new, opened or existing on load document like this: ((ApplicationEvents4_Event) Application).NewDocument += CreateTaskPaneWrapper; Application.DocumentOpen +=

c# word interop find and replace everything

房东的猫 提交于 2019-11-28 07:02:49
I have some code to replace text inside a word 2010 docx. object fileName = Path.Combine(System.Windows.Forms.Application.StartupPath, "document.docx"); Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application { Visible = true }; Microsoft.Office.Interop.Word.Document aDoc = wordApp.Documents.Open(ref fileName, ReadOnly: false, Visible: true); aDoc.Activate(); Microsoft.Office.Interop.Word.Find fnd = wordApp.ActiveWindow.Selection.Find; fnd.ClearFormatting(); fnd.Replacement.ClearFormatting(); fnd.Forward = true; fnd.Wrap = Microsoft.Office.Interop.Word

Installing Microsoft Office on a windows server?

我的梦境 提交于 2019-11-28 05:53:00
问题 I could not google a straight simple answer to this, so i'm trying my luck here. is there a problem installing Microsoft office 2007\2010\2013 on a network windows-based server, to be able to do some server-side conversions and simple automatic operations using its inter ops libraries on user generated documents? If it is, is there anything i need to know prior to installing it ? any licenses needed ? cost of these ? is it the same as installing office on a client pc ? Thanks in advance. 回答1:

Is there a way to tell PowerPoint not to open Excel when creating charts?

你说的曾经没有我的故事 提交于 2019-11-28 03:55:50
问题 Slide.Shapes.AddChart() automatically opens Excel. Even if I quickly do Chart.ChartData.Workbook.Application.Visible = false , it still shows a little while. This makes automating chart creation error-prone as the user has to try not to touch the Excel applications that keeps popping up. Opening a presentation with WithWindow = false will still open Excel when creating new charts. 回答1: This behavior is "by design" and Microsoft is not interested in changing. This is the way the UI functions.

Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))

旧城冷巷雨未停 提交于 2019-11-28 01:55:30
问题 I have a small C# Winforms Application that is using Word.Interop to Take a Single Mail Merge Document, copy each section, paste that section into it's own document, and save it individually. I keep (sometimes randomly) getting the error message: Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED)) . I have tested my below code and when I use breakpoints, I never receive this message. However, if I let it run uninhibited, it seems to error out at my line

Add a row to an MS Word table using Office.Interop

懵懂的女人 提交于 2019-11-28 01:55:25
I have a word template with a table that I am populating from a list of strings that I split using tab characters. I do not know how many lines of text I will have as it will vary. So I am adding a row programmatically before iterating through my loop like this: oWordDoc.Tables[2].Rows.Add(oWordDoc.Tables[2].Rows[1]); Unfortunately it is adding the row before rather than after the current row. How can I change my code to always have an empty row added after the current row? Leave the parameter value as a missing value for the Row.Add Function object oMissing = System.Reflection.Missing.Value;

Error reading word doc using Micorsoft.Office.Interop(Object library) via IIS 7

这一生的挚爱 提交于 2019-11-28 01:45:59
Iam facing issue while reading the document when runnning code from IIS. It is not reading the document and throwirng an error "No document is opne when trying to save the activedocument.". m_word.Documents.Open(ref FileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); m_word.ActiveDocument.SaveAs2(ref FileName_rtf, ref FileFormat, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1, ref missing1,

Inserting A Line Break (Not A Paragraph Break) Programatically To A Word Document

▼魔方 西西 提交于 2019-11-28 00:54:17
问题 I am using the Office Developer Tools for Visual Studio 2013 in C#. Ever since Word 2007, adding a "\n" character adds a paragraph break (which adds more space than the line break in Word). How can I add a line break to a document? I've tried "\n", "\r", and "\r\n" all of which seem to add a paragraph break. 回答1: It turns out that Word uses Vertical Tabs for its line breaks. I was able to add them using the "\v" character to ranges. See What is a vertical tab? for more details. 回答2: I've