office-interop

VSTO Alternatives [closed]

陌路散爱 提交于 2019-12-06 02:51:34
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . What alternatives exist for VSTO? What does managedxll do that VSTO does not - When would you use one vs the other Google does not bring much up on this subject This is more of an interview question - What are the pros and cons and both is the crux of the question here VSTO presumes you are using Visual Studio as your development platform, thus mainly targeting professional and corporate developers. 'Power users

Is it possible to store hidden metadata information that is tied to a specific Table or Cell within a Word document?

安稳与你 提交于 2019-12-06 02:29:53
问题 I am trying to store metadata (basically a unique id) along with each cell of a table in a Word document. Currently, for the add-in I'm developing, I am querying the database, and building a table inside the Word document using the data that is retrieved. I want to be able to save any of the user's edits to the document, and persist it back to the database. My initial thought was to store a unique id along with each cell in the table so that I would be able to tell which records to update. I

How to programmatically create a powerpoint from a list of images

懵懂的女人 提交于 2019-12-06 01:37:09
问题 I've seen this question: Creating PowerPoint presentations programmatically, but that question asks "Can you?" to which the answer is "yes". But I'm asking "How?" and specifically "From a list of images?" Here's what I do to break a ppt up into images var app = new PowerPoint.Application(); var pres = app.Presentations; var file = pres.Open(input, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse); file.SaveAs(output, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType

How to load Word document from byte array

五迷三道 提交于 2019-12-06 01:35:37
问题 I have the whole MS Word file itself saved into a byte array.A want to load it the way I would if it was on file system but with the minimal use of Microsoft.Office.Interop.Word because it is very slow when it gets the the .Open(args[]) part. 回答1: Try this.... byte[] bte = File.ReadAllBytes("E:\\test.doc"); // Put the Reading file File.WriteAllBytes(@"E:\\test1.doc", bte); // Same contents you will get in byte[] and that will be save here 回答2: There is no supported way to do it right off-the

Interop.Word print preview dialog for office 2010/2013

喜夏-厌秋 提交于 2019-12-05 19:04:15
In my application I have word template with tags which are later replaced using interop.word (find/replace) and then sent to print using print preview dialog: Interop.Word.Application.Dialogs[WdWordDialog.wdDialogFilePrint] On a result of a dialog I am printing or closing the document. For office 2003 and 2007 this is working absolutely fine, but in office 2010 later print preview dialog is absolutely different. I've found related post here but I need to grab dialog result so that i could further do print or close the doc. Is there any workaround or soultions for that? Just for the future

C# Word Interop - Spell Checking in a Certain Language

眉间皱痕 提交于 2019-12-05 17:22:06
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 direction? Found my solution: foreach (Range range in activeDocument.Words) { range.LanguageID = WdLanguageID

Can you paste a block of cells in one shot using Excel Interop w/o using the clipboard?

喜夏-厌秋 提交于 2019-12-05 16:36:08
I'm trying to transfer data from a DataSet into an Excel workbook. Unfortunately, I need more control than I can get by simply linking to Excel via ADO.NET and using standard SQL to select and insert the data, so I'm using excel interop. My original algorithm involved looping through all the tables/rows/items of the data set and individually setting the Formula of each cell in Excel. This worked, but it was taking nearly half a minute to transfer all the data. I decided to try a different solution: convert each table to a tab-delimited string (using a combination of StringBuilder and string

Word Automation - Disable Alerts

白昼怎懂夜的黑 提交于 2019-12-05 16:34:03
I am automating Word, so I would like to suppress all alerts. Word.Application word = new Word.Application(); word.DisplayAlerts = Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone; I use the code listed above, but I keep getting messages from Word - e.g., the document is already open. Is there a way to avoid this? How to supress all those stupid messageboxes? EDIT : Concider to all answers, I guess a watchdog is really the only option. To bad nothing has changed in last years. Thread can be closed without a real answer. The portion of code that you have posted obviously looks correct,

C# Create Excel workbook with 1 sheet by default

半腔热情 提交于 2019-12-05 16:20:40
问题 I'm trying to create an Excel file with C# COM interop but seems it create it by default with 3 sheets instead of empty or only one. What is needed to create it Empty or just with one: Excel.Application xl = null; Excel._Workbook wb = null; // Create a new instance of Excel from scratch xl = new Excel.Application(); xl.Visible = true; wb = (Excel._Workbook)(xl.Workbooks.Add(Missing.Value)); wb.SaveAs(@"C:\a.xls", Excel.XlFileFormat.xlWorkbookNormal, null, null, false, false, Excel

Filling Word template fields with C#

谁都会走 提交于 2019-12-05 16:09:36
Currently, if I create a Word Document Template with fields, and then fill them using C#, I do it similar to this... object missing = Type.Missing; Word.Application app = new Word.Application(); Word.Document doc = app.Documents.Open("file.doc", ref missing, true); Word.FormFields fields = doc.FormFields; fields[2].Result = "foo" fields[3].Result = "bar" Is there a better way to reference the fields? I notice when creating the template I can add a Title and a Tag to the field, but I haven't found a way to reference those properties. It would be nice to be able to name fields and reference them