office-interop

Using Microsoft.Office.Interop.Word assembly

徘徊边缘 提交于 2019-11-30 22:53:27
I have to do a word document programming in c#. Is there any way to access Microsoft.Office.Interop.Word assembly without installing Microsoft word? I tried to install Office Primary Interop Assemblies But it ask me install Microsoft Office package first. Have you tried the PIA Redistributable for whatever version of Office you are trying to work on? The Office 2010 PIA redistributable, for example, does not list Office as a requirement (but of course that could be an error in the System Requirements section). http://www.microsoft.com/downloads/en/details.aspx?FamilyID=938fe8ad-583b-4bd7-a345

Different First Page in a document using microsoft office interop word in c#

不羁岁月 提交于 2019-11-30 21:10:38
问题 How can i create a different first page header and footer in a document using Microsoft.office.interop.word. I have tried the following code but only in the first page, header and footer is coming. I want it in the other way(first page shouldn't have header and footer). can any one Please help me ? i tried a lot. Microsoft.Office.Interop.Word.Application w = new icrosoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document doc; w.ActiveDocument.PageSetup

Communicating between C# and VBA

前提是你 提交于 2019-11-30 19:53:06
At the request of my boss I created a small set of scripts that are used to periodically monitor the status of certain devices and processes. This info is subsequently processed using a relatively elaborate VBA module that gathers all info, applies formulas, sets up ranges and generates graphs, etc. There are two problems however: I'm an amateur programmer, so my VBA routine is quite inefficient. That's not a huge problem for me (I just get up and get a coffee while it's running), but for other users this can be a hassle, as then don't know why it's taking so long. I want a graphical

Looking up the value for MS Office Interop constants rather than hard coding them

↘锁芯ラ 提交于 2019-11-30 19:41:22
Using PowerShell, it is easy enough to create, say, an instance of the Excel Application class and start manipulating it: $app = New-Object -ComObject "Excel.Application" However, if I need to use the constants like xlDoubleQuote or xlDelimited - it seems like I am forced to hard code them. I would really like to be able to do something like: $constants = New-Object -ComObject "Excel.Constants" $constants.xlDoubleQuote And see that it would return the value of 1. Unfortunately I can't create an instance of an enumeration, and there doesn't seem to be a way to reference it like you would a

Using Microsoft.Office.Interop.Word assembly

荒凉一梦 提交于 2019-11-30 18:26:19
问题 I have to do a word document programming in c#. Is there any way to access Microsoft.Office.Interop.Word assembly without installing Microsoft word? I tried to install Office Primary Interop Assemblies But it ask me install Microsoft Office package first. 回答1: Have you tried the PIA Redistributable for whatever version of Office you are trying to work on? The Office 2010 PIA redistributable, for example, does not list Office as a requirement (but of course that could be an error in the System

what is the advantage of .net4's new no pia feature [deploying PIA's]

混江龙づ霸主 提交于 2019-11-30 17:50:01
问题 Its possibly im just missing something here but, when I write some code for Excel interop, here is how it goes. I add a reference to the Excel Com libraries. VS creates a PIA - Microsoft.Office.Interop.Excel....(via tlbimp right?). I copy the exe and the interop(PIA) dll to any machine (with .net) and it works? Is there a scenario where I would have to deploy/register the PIA? Or have I got something wrong here, because it seems to me embedding the PIA into the main assembly doesn't seem like

Filling fields in Word using c# and Microsoft Word Interop

北战南征 提交于 2019-11-30 17:48:58
I tried to Fill out Form Fields in Microsoft Word using C# Interop Assemblies with the following Code string filename = @"N:\mehler\Vorlage2.dotx"; Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document doc = new Microsoft.Office.Interop.Word.Document(); doc = word.Documents.Open(filename); doc.Activate(); foreach (Microsoft.Office.Interop.Word.FormField field in doc.FormFields) { switch (field.Name) { case "Text2": field.Range.Text = "1"; break; default: break; } } doc.SaveAs2(@"N:\mehler\Ausgefuellt.docx"); doc

VSTO (Document-level): Individual context menu in Excel (right click menu)

我只是一个虾纸丫 提交于 2019-11-30 15:18:25
问题 Is it possible to disable or configure the (cell, range) context menu via C# (VSTO). If yes, how can I implement it (in a document-level VSTO Excel application) For example I want to disable some items in the context menu (e.g. copy/paste) and add new items or replace the standard context menu with a complete own menu! Are Smarttags a good alternative to context menues in Excel? 回答1: Here's some rough sample code with comments This was created in VS2010 and tested against Excel 2010 First

VSTO Unit Testing Office AddIn in C# .NET via RequestComAddInAutomationService

↘锁芯ラ 提交于 2019-11-30 14:34:55
I have worked and read through various StackOverflow questions and other tutorials and documentation over the past weeks (N.B. some of them below) to try and find a way of unit testing a VSTO AddIn. Unfortunately, it always results in an E_NOINTERFACE exception in my tests. The code I am using is below - one extract of the ThisAddin partial class overriding the RequestComAddinAutomationService , another describing the test utility interface, the test itself, as well as an additional assembly extract proving that the AddIn assembly and its internals are visible to the test. My question is : why

VSTO (Document-level): Individual context menu in Excel (right click menu)

给你一囗甜甜゛ 提交于 2019-11-30 14:20:55
Is it possible to disable or configure the (cell, range) context menu via C# (VSTO). If yes, how can I implement it (in a document-level VSTO Excel application) For example I want to disable some items in the context menu (e.g. copy/paste) and add new items or replace the standard context menu with a complete own menu! Are Smarttags a good alternative to context menues in Excel? Here's some rough sample code with comments This was created in VS2010 and tested against Excel 2010 First step was to created a new Excel 2010 Add-In project Then added the sample code below to the default code