ms-word

Previewing documents (Word, Excel, PDF, text file, etc) within C# WinForms?

社会主义新天地 提交于 2020-02-04 01:06:32
问题 I am developing a C# WinForms application, and I would like to be able to "preview" various document types within it. That is, when a user selects a filename from a list, it shows below, within the same form, a preview of the selected file. It's a lot like they way Outlook allows you to preview a selected message without double-clicking. Is there any way to take just a filename and create a control dynamically within my WinForms application that shows the contents of that file? 回答1: If you

Find a range of text with specific formatting with Word interop

妖精的绣舞 提交于 2020-02-02 12:51:48
问题 I have a MS Word add-in that needs to extract text from a range of text based solely on its formatting: in my case in particular, if the text is underlined or struck through, the range of characters/words that are underlined or struck through need to be found so that I can keep track of them. My first idea was to use Range.Find , as is outlined here, but that won't work when I have no idea what the string is that I'm looking for: var rng = doc.Range(someStartRange, someEndRange); rng.Find

Is there a way of making beautiful tables for Word in R?

一世执手 提交于 2020-02-02 03:49:17
问题 I ask my question on SO and this is my last hope :-) I have to produce a report on Word. I work on R Markdown where I have to produce many tables. I wish my tables were beautiful! But everything I tried ( pander , KableExtra , flextable ) did not work. I take results from coxph models, I aggregate them and then I construct my data.frame which looks like this : 1 Model 1 Model 2 2 n= 375 n= 374 3 e= 65 e= 64 4 PH= 0.46 PH= 0.97 5 Weight --- 1.0 [ 1.0 ; 1.1 ] p = 0.03 6 Size --- 1.0 [ 1.0 ; 1.0

Adding tables in word document in loop

北战南征 提交于 2020-01-30 12:27:05
问题 I want to add multiple tables in word document programmatically. I have tried following code in order to add table (in sample code below I have not used loop though) Microsoft.Office.Interop.Word.Table imageTable1 = wordDoc.Tables.Add(initialRange, 1, 2, ref oMissing, ref oMissing); imageTable1.Rows.SetHeight(40, WdRowHeightRule.wdRowHeightExactly); imageTable1.AllowAutoFit = true; var text = "ABC"; // Add feature name in bold in table if (!string.IsNullOrEmpty(text)) { Cell cell1 =

Problem using two font formats in Word header

一笑奈何 提交于 2020-01-30 12:21:45
问题 From an subroutine in Excel, I am trying to create a header in a Word document with two words each with different font formatting however the last font formatting wins. Any help would be appreciated! Below is my current code snippet. With myDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range .Font.Name = "Courier New" .Font.Size = 10 .Font.Bold = True .Font.Color = wdColorGreen .text = "TEXT LINE 1" & vbLf .Font.Name = "Calibri Light" .Font.Size = 16 .Font.Bold = False .Font.Color =

How I can export from a DataTable to a Content control in C# using Openxml?

流过昼夜 提交于 2020-01-30 11:49:54
问题 So I have this code, but i want to know how possible it is to convert from a result gotten from an SQL DataTable to print on a Microsoft word content control My code looks something like this public bool PrintTableonContentControl(string connectionString, string DbQuery,string filePath, string placeholderText) { try{ DataTable dt = new DataTable(); using(SqlConnection con = new SqlConnection(connectionString)){ con.Open(); using(SqlCommand cmd = new SqlCommand(DbQuery,con)){ using

Open .docx with Apache POI and save it with password

我的未来我决定 提交于 2020-01-30 11:34:06
问题 The goal is to open existing .docx document and save it encrypted with password. I use Apache POI library for that. The code below works fine and makes document encrypted and password protected. But after the file creating I can open it with the LibreOffice but can't with the MS Word or OpenOffice Writer. It seems that the file has no content type part cuz OpenOffice asked me about file's filter. But when I choosed "Microsoft Word 2007 XML" I got the "Common Input-Output error" from the

VBA to copy text from excel to on specific location in wordfile

限于喜欢 提交于 2020-01-30 11:01:09
问题 Problem: Pasting copied data from excel to specific location in a word file. Currently I have code which can paste the value, but it does so to "paragraph1" myDoc.Paragraphs(1).Range.Paste How do I specify the exact location (by line) in which to paste the data? Let me know if more info is required. Thanks! Mohd Akhtar 回答1: You could also use some bookmarks: You can choose where you put your bookmark and then write on it like this ThisDocument.Bookmarks("NAME_OF_THE_BOOKMARK").Range.Text =

Rmarkdown output to word creates one table instead of two

我的未来我决定 提交于 2020-01-30 06:19:50
问题 Rmarkdown output to word creates one table instead of two The code below is expected to create two independent tables when I knit a Word document using Rmarkdown in Rstudio, but instead it creates one combined table. Code expected to create a word document with two tables: --- title: "Untitled" output: word_document --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) ``` ## R Markdown ```{r} knitr::kable(head(iris)) ``` ```{r} knitr::kable(head(iris)) ``` But it only creates

Access word checkboxlist and check if check mark in checkbox

随声附和 提交于 2020-01-26 04:02:45
问题 I have a button that creates checkedlistbox inside a table in word. the problem is that I can access the checkedlistbox only inside the function and if I am doing this inside the scope, I can only access the last checkedlistbox the code: { Microsoft.Office.Tools.Word.Controls.CheckedListBox listBox1; Document extendedDocument = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument); extendedDocument.Paragraphs[1].Range.InsertParagraphBefore(); listBox1 = extendedDocument