I prepare a table in Excel within a Using () statetement. At the end I UsedRange.Copy() to what I understand is the clipboard. Then I Selection.PasteExcelTable in a Word document. I get an COM Exception "command failed". When I activate the word document and press Ctrl+V the table gets copied. I wonder if that has something to do with the fact that maybe I must reactivate the Word document in code. The word document gets created also within a Using() statement. I execute the Excel procedure from within the Using(Word) statement.

Member Avatar
+0 forum 0

When I execute this progammatically, I get a table with row heights much larger than when I do this manually. Note : Sel is the Word.Selection object and the Clipboard contains an Excel Table. public void AddClipboard() { Sel.PasteExcelTable(false,false, false); var t = Sel.Tables[Sel.Tables.Count]; t.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent); }

Member Avatar
Member Avatar
+0 forum 2

Hi have this code that runs well for me. It's part of my WordWrapper where Sel is defined as the Selection object. I tried to save `Sel.Font to a var f` variable, and reset `Sel.Font = f`before exit, but that does not work. "Value out of range". /// <summary> /// Write String Bold/Underline/Size 14. /// </summary> /// <param name="s"></param> public void Header(string s) { var b = Sel.Font.Bold; var u = Sel.Font.Underline; var size = Sel.Font.Size; Sel.Font.Bold = (int) Word.WdConstants.wdToggle; Sel.Font.Underline = Word.WdUnderline.wdUnderlineSingle; Sel.Font.Size = 14; Sel.TypeText(s); Sel.Font.Bold = b; Sel.Font.Underline = u; Sel.Font.Size = size; }

Member Avatar
Member Avatar
+0 forum 1

This week I'll be at InterOp Las Vegas looking for the latest and coolest Linux-based technologies that InterOp exhibitors have to offer. My favorites are certainly the "new innovators." New innovators are small companies who've developed their own products and are trying to get noticed in the high-tech space. These are the best and most enjoyable people to talk to at such shows. You'll benefit from the trip indirectly through this blog since I'll be reporting on who and what I find there. What I'm looking for specifically are companies whose founders are: 1. - Dedicated to the Open Source …

Member Avatar
Member Avatar
+0 forum 1

Hi, Getting some strange behaviour when using Interop to create a Word document from a template. I'm using word to generate a nicely formatted and printable Receipt from Sage 200 based on a Word Template. The code should open Word then create a new document based on the template I have created with bookmarks to populate with the receipt data. The issue is that instead of seeing a single document, I see about 5-6 documents appearing! One of the documents is based on the template I want and the rest are all blank. Also, the document based on the template …

Member Avatar
Member Avatar
+0 forum 3

I have been trying to call a C++ function in a DLL, from a C# WPF application I'm working on. I've done it before and it's worked but I can't remember how I did it and can't seem to find an example that works for me. I'm doing something wrong somewhere but I can't work out where. I've created a project that produces a DLL in C++ with /clr set, and then created a C# WPF project added a button and then added the DLL reference to the WPF project. Both projects and in the same solution, the DLL compiles …

Member Avatar
Member Avatar
+0 forum 7

Hi, This is a problem googled easily, but no solution helped me. Locally I am trying to open a PowerPoint application to read and import a ppt (or pptx) file. this is the command where exception is thrown (ASP.NET VB): [CODE] objApplication = New Microsoft.Office.Interop.PowerPoint.Application [/CODE] the exception text is something like: Retrieving the COM class factory for component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} failed due to the following error: 80040154. The solutions I googled are: 1.run dcomcnfg, find Microsoft Powerpoint application, 2. give permissions to ASPNET user. This could not help, because --> On a computer, where there was a MS …

Member Avatar
Member Avatar
+0 forum 7

i created a report which exports to excel. it exports just fine. what i want to do now is merge the consecutive cells in a column which have the same values. how do i do this? please help me. this is code that generates the excel body: Protected Sub generateExcelBody(ByVal xcelworksheet As Microsoft.Office.Interop.Excel.Worksheet, ByVal recarray As Array, ByVal numofrecords As Integer) Dim chartrange As Microsoft.Office.Interop.Excel.Range chartrange = Nothing chartrange = xcelworksheet.Range("B5", "F5") chartrange.MergeCells = True chartrange.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft chartrange.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter chartrange = Nothing chartrange = xcelworksheet.Range("A8", System.Reflection.Missing.Value) chartrange.FormulaR1C1 = "Record Series : " & hiddenrs.Value chartrange = Nothing chartrange …

Member Avatar
+0 forum 0

Hello everyone! I need to anticipate that I am very new to the Microsoft developing world, therefore I am not confident with Visual Studio. I need to write an application for a windows server that works with excel. Looking on the web I found that the best method would be to use Microsoft.Office.Interop.Excel. Therefore i put the using Microsoft.Office.Interop.Excel; line at the beginning of the code and, when comiling I told csc the reference using /r:Microsoft.Office.Interop.Excel.dll . The problem is that the compiler tells me that the metafile Microsoft.Office.Interop.Excel can't be found. How can I proceed with this? Thanks in …

Member Avatar
Member Avatar
+0 forum 5

Does anyone here know what is wrong with my code here? I am trying to write a c# library for use in VB6. I think I have tried just about everything on google and still continue to get the message "ActiveX component can't create object". I am a total VB6 noob but I'd say I'm at least intermediate with c#. Heres what I tried: 1. Set the make assembly COM-Visible option in the project properties 2. Checked 'register for com interop' in the build output 3. Ran regasm with and without /codebase on the dll file, and made a tlb …

Member Avatar
Member Avatar
+0 forum 2

I am facing a small problem. Something i might have mis understood. If u see the code without using a function if i print the message then i am getting proper output. But after i create Error function and print message from main function it is creating some problem. I am not sure is to why this is the case. Help would be appreciated. [CODE]using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Runtime.InteropServices; namespace Test { class Program { unsafe static void Main(string[] args) { char* errMsg = (char*)Marshal.AllocHGlobal(255); //ShrinkError(errMsg); errMsg = (char*)Marshal.StringToHGlobalAnsi("This is just testing ... …

Member Avatar
Member Avatar
+0 forum 1

Hi I had written an in VB.net that took addresses from a database put them into a csv file then took the csv file data and performed a mail merge in Word to allow the user to print them out on to an Avery L7163 label sheet. The app was working fine until our company upgraded from Windows XP with office 2000 to Windows 7 with Office 2010. Instead of getting the labels populated with the address data there are what appear to be form fields printed e.g. <<Address 1>>. Also they are not appearing in the order they should …

Member Avatar
Member Avatar
+0 forum 2

I am using Excel interop in my VB.NET program. My problem is that I can't seem to figure out how to write to Excel *and* define the Range using numbers. Alright, so I have objects being created depending on the file that the user opens. So there could be 100 objects or there could be none. Now each object has an array of values, and these arrays contain nearly 15000 elements. So here is what I want to do but I can't figure out how to escape using the LetterNumber:LetterNumber combination. For every object I want a new column to …

Member Avatar
Member Avatar
+0 forum 3

I have a .NET winforms app that automates Excel and checks for a worksheet password. The requirements are to be able to detect 1) that the protection is turned off 2) that the password is removed (protected but there is no password) 3) that the password matches the correct password from a database To meet the second requirement the program calls the Worksheet.Unprotect command with a null string, capturing the error. If error as expected, the 3rd check is made. If no error, then the Unprotect worked without a password ==> password was removed. The code sample below has these …

Member Avatar
Member Avatar
+0 forum 1

I done an application using Power Point Interop library and it works well but if I copy it from DEBUG folder to another place, when I start it it gives me an error like: "Application has encountered a problem and needs to be close. We are sorry for the inconvenience". It just cannot start. I tried to copy the Microsoft.Interop.PowerPoint DLL in the same folder but does not work.... why? Build issue? Can somebody help please? :D

Member Avatar
Member Avatar
+0 forum 2

InterOp 2009 is a success by anyone's measure but it's been a mixed bag for me so far. Internet access on the show floor is almost non-existent. For a major tech show like this, it's absolutely ridiculous. You'd think that Internet access would be a standard feature of any technical show--especially for perhaps the largest one of the year in North America. The show floor is packed with exhibitors showing their wares (hardware appliances, security software and virtualization solutions) and eager-to-learn and buy show attendees. Most attendees report that they will increase IT spending this year. Good news for the …

Member Avatar
Member Avatar
+0 forum 1

The End.