office-automation

How to get text from line number in MS Word

北城余情 提交于 2019-12-02 02:16:54
Is it possible to get text (line or sentence) from a given line number in MS Word using office automation? I mean its ok if I can get either the text in the given line number or the sentence(s) itself which is a part of that line. I am not providing any code because I have absolutely no clue how an MS Word is read using office automation. I can go about opening the file like this: var wordApp = new ApplicationClass(); wordApp.Visible = false; object file = path; object misValue= Type.Missing; Word.Document doc = wordApp.Documents.Open(ref file, ref misValue, ref misValue, ref misValue, ref

Excel VBA Sort - Error when automated from Access 2007

Deadly 提交于 2019-12-01 13:50:10
I wrote some code in Excel 2007 VBA, which includes some sorting, and it works fine in Excel. Now I'm trying to get it to work from Access 2007, automating Excel. When I get to the Apply method, I get this error: "The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank" But the two sort keys are within the data I want to sort. Also the Key parameters of the Add method are fully qualified. Here's my code. First, this is what works in Excel: (data_sheet is a worksheet reference) With data_sheet.AutoFilter.Sort With

Excel VBA Sort - Error when automated from Access 2007

北战南征 提交于 2019-12-01 12:08:59
问题 I wrote some code in Excel 2007 VBA, which includes some sorting, and it works fine in Excel. Now I'm trying to get it to work from Access 2007, automating Excel. When I get to the Apply method, I get this error: "The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank" But the two sort keys are within the data I want to sort. Also the Key parameters of the Add method are fully qualified. Here's my code. First,

Getting a Object Reference error in prod only when trying to use the Word DocumentClass

ⅰ亾dé卋堺 提交于 2019-11-30 20:29:04
I am writing a program that uses a .dotx template and does a merge of data in an aspx page. The program works perfect on my Dev workstation locally but when I deploy it to a test IIS server, it fails on the second line below giving me an Object Reference error. I ran into problems earlier because the Word Com object was not on the IIS server so I loaded Word onto the server and set permission in DCom and got past that problem. But now I get this error on the line that starts with wRange = ..... As I said, the program works perfectly locally in debug mode. Any ideas? Microsoft.Office.Interop

Call was rejected by callee PowerPoint Automation

大城市里の小女人 提交于 2019-11-30 15:41:52
I have a commandbar model which automates PowerPoint. I recently faced a strange problem that when PowerPoint is opened through my application, and the data is being loaded through my application to populate the menu. If a user right clicks on PowerPoint I get the error message: Call was rejected by callee powerpoint How do I resolve this? I'm using Office 2003/2007 and VB.NET for office automation. Did you see this tutorial?: How to: Fix 'Application is Busy' and 'Call was Rejected By Callee' Errors To fix errors: 1. Add the following class to your application. 2. Add a COM reference to

Getting a Object Reference error in prod only when trying to use the Word DocumentClass

此生再无相见时 提交于 2019-11-30 04:50:41
问题 I am writing a program that uses a .dotx template and does a merge of data in an aspx page. The program works perfect on my Dev workstation locally but when I deploy it to a test IIS server, it fails on the second line below giving me an Object Reference error. I ran into problems earlier because the Word Com object was not on the IIS server so I loaded Word onto the server and set permission in DCom and got past that problem. But now I get this error on the line that starts with wRange = ...

Call was rejected by callee PowerPoint Automation

99封情书 提交于 2019-11-29 23:04:27
问题 I have a commandbar model which automates PowerPoint. I recently faced a strange problem that when PowerPoint is opened through my application, and the data is being loaded through my application to populate the menu. If a user right clicks on PowerPoint I get the error message: Call was rejected by callee powerpoint How do I resolve this? I'm using Office 2003/2007 and VB.NET for office automation. 回答1: Did you see this tutorial?: How to: Fix 'Application is Busy' and 'Call was Rejected By

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

老子叫甜甜 提交于 2019-11-29 15:33:44
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": FileFormatNum = 56 FileExtStr = ".csv": FileFormatNum = 6 FileExtStr = ".txt": FileFormatNum = -4158 FileExtStr

Killing EXCEL.exe Process from C# in a Windows Service

纵饮孤独 提交于 2019-11-28 23:49:43
I have a windows service that opens up an Excel spreadsheet via the Microsoft.Office.Interop.Excel.Application object. Application xlApp = new Application(); Workbook workbook = xlApp.Workbooks.Open(fileName, 2, false); ... ... workbook.Close(); xlApp.Quit(); I would like to kill the EXCEL.exe process that is left running after it is done working with the workbook. I've tried the following with no success... // This returns a processId of 0 IntPtr processId; GetWindowThreadProcessId(new IntPtr(xlApp.Hwnd), out processId); Process p = Process.GetProcessById(processId.ToInt32()); p.Kill();

IE 9 not accepting SendKeys

柔情痞子 提交于 2019-11-28 12:54:28
I posted on IE 9 not accepting SendKeys to download a file , but this problem is separate enough from the answer I received to justify another question. My problem is that I can't get IE 9 to accept any of the SendKeys . I have attempted Page Down , Tab , all of the F# keys, and none of them work. Here is the code I am using: Dim ie As Object 'This creates the IE object Sub initializeIE() 'call this subprocedure to start internet explorer up Set ie = CreateObject("internetexplorer.application") pos = 1 End Sub 'Initialize the class object Private Sub Class_Initialize() initializeIE End Sub