office-interop

How to show an Office/Word 2013 Task Pane 'Office App' after a click on a button in Ribbon?

♀尐吖头ヾ 提交于 2019-12-10 11:08:21
问题 I've created a Task Pane App with the new Office App model. It uses JQuery and a REST Service to search and display data from SharePoint in the (Word 2013) Task Pane. This works ok, however the App Task Pane should be activated after clicking on a custom button in the ribbon. To create the button, I've created a Word 2013 Addin project with following Custom UI XML: <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load"> <ribbon> <tabs> <tab idMso="TabHome"

Converting powerpoint presentations (ppt/x) to PDF without Interop

瘦欲@ 提交于 2019-12-10 10:57:35
问题 I need to convert a PowerPoint (ppt/pptx) file to PDF using C# Currently, I'm using this code: public void PPTXToPDF(string originalPptPath, string pdfPath) { // Create COM Objects Microsoft.Office.Interop.PowerPoint.Application pptApplication = null; Microsoft.Office.Interop.PowerPoint.Presentation pptPresentation = null; try { object unknownType = Type.Missing; //start power point pptApplication = new Microsoft.Office.Interop.PowerPoint.Application(); //open powerpoint document

Interop.Word Find and Hyperlink that word

和自甴很熟 提交于 2019-12-10 10:55:51
问题 I am trying to create a program which searches in a Word doc for a certain word and adds a hyperlink to that word. I can do the code to search for the word (using a FindandReplace ), and can work out how to add a hyperlink to a word doc, but I cannot work out how to hyperlink the word I searched for. I think its because I need to define the word I searched for as a Range. My code so far is: using System; using Microsoft.Office.Interop.Word; using Word = Microsoft.Office.Interop.Word; using

Checking Font Styles In Word Document Using VB.NET

孤街醉人 提交于 2019-12-10 10:24:11
问题 i want to check a word file using vb.net and check that the styles in the document are proper or not. I have to check for these expressions in word document a.Verdana + 16 pt + Bold + Red b.Verdana + 12 pt + Bold + Italic + Blue c.Verdana + 11 pt + Bold + Italic + Brown d.Arial + 10 pt + Black I have tried this, If objDoc.Range.Font.Name = "Arial" And objDoc.Range.Font.Size = 10 Then If objDoc.Range.Font.Color = WdColor.wdColorBlack Then End If MsgBox("ok") Else MsgBox("not ok") End If But

C# Word Interop - Spell Checking in a Certain Language

冷暖自知 提交于 2019-12-10 09:30:00
问题 For a customer of mine I need to force the spell checking in a certain language. I have explored the MSDN documentation and found that when calling the CheckSpelling() method in the active document, it will invoke the spelling check. This method has parameters for custom dictionaries. My problem is that I can't find anything about those dictionaries or how to use them. Also there is still the possibility that there is of course another way to do this. Can anybody boost me in the right

Color non-consecutive cells in an Excel sheet

你说的曾经没有我的故事 提交于 2019-12-10 05:19:34
问题 This is what happens: xlValues is set as an Excel.Range object. I have tried the following as well, all giving me the same error: //xlValueRange = xlSheet... .get_Range("A1:A5,A15:A25,A50:A65"); .UsedRange.Range["A1:A5,A15:A25,A50:A65"]; .Range["A1:A5,A15:A25,A50:A65"]; xlApp.ActiveWorkbook.ActiveSheet.Range["A1:A5,A15:A25,A50:A65"]; //I have also tried these alternatives with ".Select()" after the brackets and //", Type.Missing" inside the brackets //This works though... xlSheet.Range["A1:A5

Access return value from VBA Function in .NET?

我们两清 提交于 2019-12-10 04:24:40
问题 I have the following code in VBA (which resides in an Excel 2007 Workbook): Public Function Multiply(a As Double, b As Double) As Double Multiply = a * b End Function If I invoke Multiply from other VBA code, it returns the correct value. However, when I call Multiply from C#: var excel = new Application {Visible = true}; excel.Workbooks.Open(filename); var returned = excel.Run("Sheet1.Multiply", (Double) a, (Double) b); ... the multiplication takes place (I can verify this by adding tracing

using c# to select a worksheet in excel

邮差的信 提交于 2019-12-10 03:52:08
问题 Using C# in .NET 3.5 with Visual Studio 2008, I am trying to set focus (or activate) a specific worksheet in an open workbook: Here are some properties: public Excel.Application xlApp {get;set;} public Excel.Workbook xlWorkBook { get; set; } public Excel.Worksheet xlWorkSheet { get; set; } public Excel.Range range { get; set; } And here is how I am trying to select a specific worksheet: (xlWorkSheet)Application.ActiveWorkbook.Sheets[FormControls.WorksheetFocus]).Select(Type.Missing); And I

How to print a docx to a specific printer using Microsoft.Office.Interop.Word.Document.PrintOut()

好久不见. 提交于 2019-12-10 02:43:39
问题 This seems like such a simple need, but for some reason I cannot find how I can accomplish this. I have code like this: Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); MemoryStream documentStream = getDocStream(); FileInfo wordFile = new FileInfo("c:\\test.docx"); object fileObject = wordFile.FullName; object oMissing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Document doc = wordInstance.Documents.Open(ref fileObject, ref

Copy text from word file to a new word

别来无恙 提交于 2019-12-09 16:17:47
问题 I am reading the text from word file and replace some text from the readed text. var wordApp = new Microsoft.Office.Interop.Word.Application(); object file = path; object nullobj = System.Reflection.Missing.Value; var doc = wordApp.Documents.Open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); doc.ActiveWindow.Selection.WholeStory(); doc.ActiveWindow.Selection.Copy(); IDataObject data =