ms-word

Insert word document to another word document without changing the format VBA

那年仲夏 提交于 2021-02-19 05:26:43
问题 First I copy a word document doc1 to a new word document with it format via a button on a userform. Second I insert at the end of this word document (filled with doc1) a new word document doc2 (doc1 and doc2 got text and table and various colors). Each time I pressed a button on another userform to put doc2, I lose the format of doc2. Here my code: Dim docSource As Document Dim docTarget As Document Set docTarget = ActiveDocument Set docSource = Documents.Open(strFilename) ' Add the content

How to return generated file download with Django REST Framework?

北城以北 提交于 2021-02-17 15:16:51
问题 I need to return generated file download as a Django REST Framework response. I tried the following: def retrieve(self, request, *args, **kwargs): template = webodt.ODFTemplate('test.odt') queryset = Pupils.objects.get(id=kwargs['pk']) serializer = StudentSerializer(queryset) context = dict(serializer.data) document = template.render(Context(context)) doc = converter().convert(document, format='doc') res = HttpResponse( FileWrapper(doc), content_type='application/msword' ) res['Content

How to return generated file download with Django REST Framework?

爷,独闯天下 提交于 2021-02-17 15:16:50
问题 I need to return generated file download as a Django REST Framework response. I tried the following: def retrieve(self, request, *args, **kwargs): template = webodt.ODFTemplate('test.odt') queryset = Pupils.objects.get(id=kwargs['pk']) serializer = StudentSerializer(queryset) context = dict(serializer.data) document = template.render(Context(context)) doc = converter().convert(document, format='doc') res = HttpResponse( FileWrapper(doc), content_type='application/msword' ) res['Content

Does the Office.js API support multiple range selection?

强颜欢笑 提交于 2021-02-17 06:58:06
问题 I need to select multiple ranges simultaneously via the Office.js API like you can do in the MSWord UI by holding down the CTRL key and highlight multiple non-contiguous paragraphs, like the screenshot below: This attempt doesn't work. Rather than highlighting the first two instances of the word "the" in the document, it's highlighting the first, then highlight the second afterwards: Word.run(function (context) { // Set up the search options. var options = Word.SearchOptions.newObject(context

Exporting data from Excel to Word: data targets/placeholders

℡╲_俬逩灬. 提交于 2021-02-17 06:16:51
问题 In Excel I have a userform that has a ListBox being populated from an Excel table using RowSource=myTable. Now I want to select one line, press a button, and export every column from the selected row to different places on a Word document, which is a template with pre-formated text. Column1 should go to place1, column2 to place2, whatever I want... What data targets/placeholders are available in Word for inserting data? 回答1: Word has multiple possibilities for the developer to write data that

PREMATURE END OF FILE - XWPFDocument to PDFConverter

旧街凉风 提交于 2021-02-17 05:48:47
问题 Instead of appending the content of a document to CTBody Class, I am transfering all the data from a word document to an empty document using XWPFDocument class but I am getting an error as below. the error is pointed on XWPFDocument doc when I convert it to pdf fr.opensagres.poi.xwpf.converter.core.XWPFConverterException: org.apache.xmlbeans.XmlException: error: Premature end of file. FileInputStream fis = new FileInputStream("1.docx"); FileInputStream fis1 = new FileInputStream("2.docx");

Edit a workbook, whether open or closed, from Word VBA

安稳与你 提交于 2021-02-17 02:48:36
问题 I am trying to write a macro in Word so that I can save some information into an Excel file somewhere else in my computer. For this reason I wrote this: Dim exlApp As Object Dim exlWbk As Object Set exlApp = CreateObject("Excel.Application") Set exlWbk = exlApp.Workbooks.Open(FileName:="D:\database.xlsx") exlWbk.ActiveSheet.Cells(1, 1).Value = "some info" exlWbk.Close SaveChanges:=True Set exlWbk = Nothing exlApp.Quit Set exlApp = Nothing The code works perfectly fine for me, except when the

Edit a workbook, whether open or closed, from Word VBA

北战南征 提交于 2021-02-17 02:47:26
问题 I am trying to write a macro in Word so that I can save some information into an Excel file somewhere else in my computer. For this reason I wrote this: Dim exlApp As Object Dim exlWbk As Object Set exlApp = CreateObject("Excel.Application") Set exlWbk = exlApp.Workbooks.Open(FileName:="D:\database.xlsx") exlWbk.ActiveSheet.Cells(1, 1).Value = "some info" exlWbk.Close SaveChanges:=True Set exlWbk = Nothing exlApp.Quit Set exlApp = Nothing The code works perfectly fine for me, except when the

VBA Word Expand Range with one line

随声附和 提交于 2021-02-11 18:21:11
问题 First of all this is the first time I am creating a macro using VBA code. With some bits and pieces i found on the internet I tried to create the following. I am not a developer at all, I just have some basic knowledge from school. So my apologies if this is poor coding. I am creating a macro in word which highlights text from a paragraph heading until the next heading with the same style. This is done based on a list of headings I import from Excel. You can find the code I have created below

VBA Word - filling out multiple forms with pop-up window

六眼飞鱼酱① 提交于 2021-02-11 17:45:25
问题 My task: I have multiple forms in one Word document and it has to be filled out with the same information such as company name, address, tax number, etc. My experience with VBA is very limited so I used bookmarks and wrote some code: Private Sub OKbutton_Click() Dim FirmaName As Range Set FirmaName = ActiveDocument.Bookmarks("FirmaName").Range FirmaName.Text = Me.TextBox1.Value Dim FirmaNameRio As Range Set FirmaNameRio = ActiveDocument.Bookmarks("FirmaNameRio").Range FirmaNameRio.Text = Me