office-interop

Outlook MailItem.HTMLBody encoding

谁说我不能喝 提交于 2019-12-11 23:01:21
问题 I'm trying to obtain mail body in HTML format. For some mails MailItem.HTMLBody returns string with ��� characters. Visual Studio Text Visualizer output: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <!-- default_css --><style></style><!-- default_css --> <meta name="description" content=""> <meta name="keywords" content=""> <meta name="viewport" content

Unit testing vba from .net - strongly typed COM objects

杀马特。学长 韩版系。学妹 提交于 2019-12-11 20:42:51
问题 I'm trying to unit test vba by using a .net MS Test project as per a comment by Ray Vega on this thread: Best way to test a MS Access application? Here is what I have so far: using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.Vbe.Interop; namespace FarmTestSuite { [TestClass] public class UnitTest1 { Microsoft.Office.Interop.Access.Application oAccess = null; Microsoft.Vbe.Interop.VBProject vbProject = null; [TestInitialize] public void Setup() { oAccess = new

Not able to insert image after the current one in word with microsoft.office.interop.word

廉价感情. 提交于 2019-12-11 19:29:35
问题 I am trying to open an existing word file and insert image into it (image name with path being passed to the function ). Code logic is working fine but challenge is every time the new image file is inserting / place on the top of the last one.mean the latest image is displaying on very first page of the word file and the rest are accordingly. But my objective is the oldest one will be on top.Or you can say the 1st one will palace 1st and the after that 2nd ,3rd ..... Here is my code sample.

Re-defne a Paragraph Range to Include a Subset of Words in the Paragraph

≯℡__Kan透↙ 提交于 2019-12-11 17:57:59
问题 I'm using Microsoft.Interop.Word / C# to programmatically create a Word document. In a given paragraph, I need to change the color of words that occur between brackets "[" and "]" The words are variable. As I understand it, I need a Range object in order to set colors. I'm using the following code, which does not work: // Add the paragraph. Microsoft.Office.Interop.Word.Paragraph pgf = document.Paragraphs.Add(); // Insert text into the paragraph. pgf.Range.InsertBefore("JIRA Issue: " +

COM Interop Through Wine in OSX

爷,独闯天下 提交于 2019-12-11 17:27:04
问题 I am trying to write a program that modifies Office files (word, excel) programmatically using C#. Before continuing with my project, I would like to know if the COM Interop can be used in OSX by utilizing Wine, and if so, can this be done in Linux as well? 来源: https://stackoverflow.com/questions/23532327/com-interop-through-wine-in-osx

How to insert a cover page in MS Word at the beginning of the document?

梦想的初衷 提交于 2019-12-11 15:57:52
问题 I need to insert a cover page into a Word 2016 document. The building block is a cover page and has InsertOptions = (int)WdDocPartInsertOptions.wdInsertPage; //= 2 So far so good. But VSTO can only insert so: buildingBlock.Insert(range); It does insert in place of range. The event Application.ActiveDocument.BuildingBlockInsert is not raised. Using native insert cover page (tab insert --> cover page) does insert properly (and creates only one undo entry insert building block). // -------------

C#: Insert and indent bullet points at bookmark in word document using Office Interop libraries

浪尽此生 提交于 2019-12-11 14:49:35
问题 Here's my dilemma. I've been given a task to generate a specific section of an existing word document based on user input from a web front end. The back end of the system is being written in C# with the part that edits the word document using the Microsoft.Office.Interop.Word namespace. Basically, they would select from a list of available instructions, each being of the type string , which will then be used to generate the instructions part of the document, with each separate instruction

VSTO Add-In: Exception- Value does not fall within the expected range Office 2010

巧了我就是萌 提交于 2019-12-11 14:05:35
问题 I have created Word Add-In. I have created Installer Setup of it. I have installed it. It is working fine in Office 2007, 2013, 2016. But it is not working in Office 2010. It throws following error. Can Anybody suggest me how to resolve it? From: file:///C:/Program Files (x86)/EasyGrammar/EasyGrammar/EasyGrammar.vsto ************** Exception Text ************** System.ArgumentException: Value does not fall within the expected range. at System.Runtime.InteropServices.Marshal

Troubles using Powershell and Word SaveAs()

落花浮王杯 提交于 2019-12-11 13:23:35
问题 From examples on the net, I have cobbled together this script which I hope will save Word .doc files as plainText. It does not. First, the Word window appears when I have given $word.Visible = $False. Then, a dialog appears asking if I want to open a read-only copy. No one else has the document open. Why is it asking. Finally, the error message says I have a type mismatch. Why is that? PS H:\d2> .\wl.ps1 Processing : H:\d2\checklists\Extract checklist_20120306.doc Name is now: H:\d2

To sort across multiple columns in Excel using C#

和自甴很熟 提交于 2019-12-11 13:14:17
问题 I need to sort across multiple columns in Excel using C#. I am using Microsoft.Office.Interop.Excel for doing this. But the Range.Sort allows me to sort across only three columns. I want to sort across more than three columns? Is there a way that I can use the Excel.Range.Sort method to sort across more than three columns? 回答1: Before Excel 2007 you were limited to 3 sort keys - Range.Sort won't let you use more. If that's your target version then you'll need to get creative: a couple of