office-automation

How to read Microsoft Word documents in .NET? [closed]

大城市里の小女人 提交于 2021-02-11 12:18:15
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . How to read doc, docx file into .NET with C#. 回答1: I see you used the asp.net tag. You should not use the automation API (COM Interop) to run Microsoft Office products from ASP.NET or any other server application

Auto clicking on a message box using VBA

落爺英雄遲暮 提交于 2020-07-10 06:01:27
问题 I am automating testcases for my company's addin. In one of the testcases, after saving my workbook on my local machine when I try closing the workbook, I am required to click on 'Yes'- saves edited data in our database, 'No'- discards the edits or 'cancel'- simply closes the message box. I have tried using sendKeys but that didn't work for me. Eg: For clicking 'No' through my VBA code, I tried to send tab and enter keys like this: Application.Wait (Now() + TimeValue("00:00:10")) Call

Errors when calling certain Excel VBA macros from C#

血红的双手。 提交于 2020-01-23 08:13:46
问题 I have been struggling and searching on this problem to no avail... I have a few test macros that work perfectly when run from Excel, but either fail or don't work when called from C#, using the interop... I am using MS Visual Studio 2012 (on 64 bit Windows 7) to create a console application that will call the VBA macro TestMacro() written in Excel 2007. Here is the C# code to call the macro: (I basically copied what was done here Run Office Macros by Using Automation from Visual C# .NET)

Check for hung Office process when using Office Automation

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 13:56:47
问题 Is there a way to check to see if an Microsoft Office process (i.e. Word, Excel) has hung when using Office Automation? Additionally, if the process is hung, is there a way to terminate it? 回答1: Let me start off saying that I don't recommend doing this in a service on a server, but I'll do my best to answer the questions. Running as a service makes it difficult to clean up. For example with what you have running as a service survive killing a hung word or excel. You may be in a position to

Programmatically encrypt Outlook email using Inspector

百般思念 提交于 2020-01-11 11:02:50
问题 I'm using C# with Outlook Object Model (Redemption is not an option for me due to licensing) and I'm having difficulty programmatically encrypting an email message before sending it. I can successfully get a reference to the CommandBarButton which supposedly represents the Encrypt button (Id 718 according to online examples), but I cannot programmatically depress it. I tried using both the CommandBarButton Execute() method and using SendKeys (not sure if sendkeys is even valid in this context

What is the FileType number for PDF in Excel 2007 that is needed to save a file as PDF through the API?

家住魔仙堡 提交于 2020-01-10 05:37:46
问题 I need to call a function in order to save an Excel workbook. I installed the PDF save addon for Excel 2007 but now I need to know what the number code is for the file format for when I save the excel file. An example of the excel file format numbers can be found here. http://www.dailydoseofexcel.com/archives/2006/10/29/saveas-in-excel-2007/ FileExtStr = ".xlsb": FileFormatNum = 50 FileExtStr = ".xlsx": FileFormatNum = 51 FileExtStr = ".xlsm": FileFormatNum = 52 FileExtStr = ".xls":

Can't replace the footer text in a word application through Delphi

瘦欲@ 提交于 2020-01-04 11:11:34
问题 I am trying to replace text in a footer, I am using the following code through which i can replace the normal content (body) but not the content in the footer/header myWinWordApp := CreateOLEObject('Word.Application'); myWinWordApp.visible := true; myWinWordApp.documents.open('c:\ole.doc'); myWinWordApp.Selection.Find.Text := 'oo'; myWinWordApp.selection.Find.Replacement.Text := 'aa'; myWinWordApp.Selection.Find.Execute(Replace := 2); any help is highly appreciated. Thanks in advance 回答1:

asp.net web service using office 2010 COM

烈酒焚心 提交于 2019-12-28 03:11:20
问题 I am writing a web service and would like to change the .docx or .doc to .xps. I'm using office com to help me to save as .xps format as following: [WebMethod] public string GetDocPreviewUrl(string m_userName, string m_orgFileName) { string m_returnUrl = ""; string m_orgFilePath = _currentDirectory + "\\" + m_userName + "\\" + m_orgFileName; if (File.Exists(m_orgFilePath)) { string m_xpsFilePath = _currentDirectory + "\\" + m_userName + "\\" + Path.GetFileNameWithoutExtension(m_orgFileName) +

asp.net web service using office 2010 COM

无人久伴 提交于 2019-12-28 03:11:09
问题 I am writing a web service and would like to change the .docx or .doc to .xps. I'm using office com to help me to save as .xps format as following: [WebMethod] public string GetDocPreviewUrl(string m_userName, string m_orgFileName) { string m_returnUrl = ""; string m_orgFilePath = _currentDirectory + "\\" + m_userName + "\\" + m_orgFileName; if (File.Exists(m_orgFilePath)) { string m_xpsFilePath = _currentDirectory + "\\" + m_userName + "\\" + Path.GetFileNameWithoutExtension(m_orgFileName) +

How to add a checkbox control to an Excel cell programatically or check or uncheck an existing checkbox

别等时光非礼了梦想. 提交于 2019-12-25 01:17:40
问题 I am using the Excel COM object in C# and want to insert a checkbox dynamically to an Excel sheet and make it checked or unchecked based on a condition. OR how can i mark as checked an existing checkbox in the Excel sheet programatically. I have looked around and I didn't find any solution. 回答1: You can always record a macro in MS Excel and it will give you a good idea of what needs to be done with Excel object in order to achieve something. For example, when recording macro for your problem,