office-interop

Obtaining Excel worksheet reference by worksheet name via C#

别等时光非礼了梦想. 提交于 2019-12-04 00:45:13
I'm currently obtaining a handle to a Excel worksheet by using the below C# code: Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(15); //Get the worksheet "SubSignOff" number Is there any way that I can obtain the same by using the worksheet name "SubSignOff" ? Mike Rosenblum Instead of the using Excel.Workbook.Sheets collection, it's easier to access the Excel.Workbook.Worksheets collection, that way you can utilize early binding. In your case, it could look something like the following: Excel.Application excelApp = new Excel.Application(); excelApp.Visible = true; Excel.Workbook

How to read MS Word paragraph and table content line by line

爷,独闯天下 提交于 2019-12-03 21:31:31
I am reading word document in C# (3.5) using Microsoft.Office.Interop.Word . Reading line by line, splitting line into array[] and processing every word of line and based on some business logic replacing some words and after the replacement of words, replacing the complete line with converted line. Till now Every thing is working fine. Now i have some word documents, those are having paragraph and tables. I want to read every Column of the table one by one and replace the content of the column in particular column. Update Using Office Automation 1. Opening word file. 2. Moving cursor to top of

More C# Automating to Excel

有些话、适合烂在心里 提交于 2019-12-03 21:13:34
This launches a fresh Excel workbook: Excel.Application oXL; Excel._Workbook oWB; oXL = new Excel.Application(); oXL.Visible = true; oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value )); However, what if one wants to either... -- 'GetObject' (in the familiar Automation paradigm) to a workbook that's already loaded and open on the screen?, or -- access and write data to a closed workbook by path name? Both of which are doable by old standards. Preferably the latter although I'm not a chooser right now. Thanks for any help. You can get an existing instance of Excel using: Marshal

List all the softwares installed on Network Computers by IP address

。_饼干妹妹 提交于 2019-12-03 20:32:11
How to get list of the softwares installed on Network Computers. I am able to get the list of software installed for my local machine but not getting any idea of how I can extract the details of installed software on the computers within the network. I have server name or IP address of the network computer as the only input. Please guide me and help me to achieve this. Below is the code which I had implemented untill now which is getting details of installed softwares from local machine: const string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; private void

Adding hyperlinks in Excel[2007] in C# - Within Excel it self

故事扮演 提交于 2019-12-03 17:15:18
问题 Can anybody tell me how we can add a hyperlink in Excel (2007 or later) from a cell in one sheet to a cell in another sheet using Office Interop in .NET (c#) For example: A hyperlink from Sheet1 Cell A1 to Sheet2 Cell B10 回答1: What you want to use here is the Hyperlinks.Add method. You can call it with code that looks something like this: Excel.Worksheet worksheet = (Excel.Worksheet)workbook.Worksheets[1]; Excel.Range rangeToHoldHyperlink = worksheet.get_Range("A1", Type.Missing); string

OneNote 2013 Add-in won't load. How to debug?

好久不见. 提交于 2019-12-03 17:14:32
I'm following the excellent tutorial by Malte Ahrens on how to create a OneNote add-in. Initially I followed it step by step, making a few changes (just renaming the class, and using my own name and GUID in the assembly) info. As I'm using VS2012 and am not yet ready to hand-roll a WiX installer I manually copied over the built dll to the correct place and also created a registry file to make the requisite entries. I confirmed that they were all there, loaded up OneNote but no add-in, going to "mange COM addins" section I saw the following error: Load Behavior: Not loaded. A runtime error

Programmatically set Outlook 2013 Signature Defaults?

风流意气都作罢 提交于 2019-12-03 16:29:05
Is it possible to programmatically set the Outlook 2013 Default Signature settings? We can generate the user's signature OK but would like to also set the signature to appear by default in user's emails: The setting itself seems to be tucked-away in the Registry under an Outlook profile: HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6677\00000002 Reg Values: New Signature Reply-Forward Signature ... (which have binary data, presumably encoding the HTML file name/reference). Not sure if I can use the Outlook Object Model to access and set

Why doesn't Word “come to front” when we activate it?

久未见 提交于 2019-12-03 14:39:25
Our winforms application interacts with MS Word and we run this code when a document is generated and we want to show it in Word in front of our application: [setup w as a Word interop object] w.Visible = True w.Activate() When rolled out to XP machines running Office 2007 this works as intended. On Win7 machines running Office 2010 the document loads behind our application and flashes on the taskbar. Any ideas? I stumbled upon a similar problem recently. My .NET program called a COM application, but on Win7 it would sometimes neither show up in taskbar nor on the desktop at all. I wasn't

Excel automation: PDF export causes “Printer setup” popup

懵懂的女人 提交于 2019-12-03 14:27:38
I am developing an application for automatic Excel to PDF generation. Every now and then (and without any apparent cause, the following popup comes up while the program runs: Print driver host for 32bit applications stopped working. and, shortly after, this one: Printer setup What, if anything, do I need to do here? My application is not overly complex. The error always (100%) happens on this line: _application.ActiveWorkbook.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, pdfTemplatePath, Excel.XlFixedFormatQuality.xlQualityStandard, _, _, 1, pdfPrintAreaEnd); where the variables in

Automating MS Word in Server 2012 R2

邮差的信 提交于 2019-12-03 13:16:09
Firstly, please don't reply with the generic advice not to automate Word on a server or a link to the MS web page on "how to automate word on a server if you really must". I am aware of this. I have a process which runs as a Windows service and uses .Net OLE interop to automate Office (mostly just Open and SaveAs). This code has worked reliably for 8 years on literally hundreds of servers using many combinations of Windows and Office versions, both 32 and 64 bit, so I am happy that the mechanism is reliable. So far... With Server 2012 R2, it works with PowerPoint and Excel but fails trying to