I am looking to merge two documents, however it is not your typical merge.
My first document is a mailmerge, creating a cover letter, basically each page has a name and address
My next document is a static document that cannot be changed.
I need to insert the static document into my first merged document, but after every page, therefore, for every one page a document is inserted.
I have tried the insert document in both word 2010 and pdf using adobe acrobat, and as you have thought it only inserted one document after the first page.
I'm looking at VBA, but I have never utilized VBA and word before
Any pointers would be appreciated.
Many thanks
I should have spent more time on this.
The original template contains fields to merge.
On the static document that I mention, click insert tab, Text Section, select Object - Text From File
Select the cover letter / template that contains the fields to merge. This will insert the template followed by the static document that cannot be changed
Note I have spotted some formatting changes on the template following merge - further work required
From this point start your mail merge, and complete merge to Adobe or word.
This creates a mail merged document containing the cover letter with name and address fields followed by the static document.
Extremely simple. I always over complicate things!
I'll work on the changed formatting, but other then that this works
Related
I have a list of strings (e.g. "A3.11.2.3", "A3.2.1" and "A12.1.3(b)") and need to find a streamlined way to extract the page number(s) on which each sting appears from PDF and Word files.
The list of strings is fixed/can be hardcoded though it would be better if they were read from a particular excel file. The Flow I am trying to create is:
When a file is created;
Search file for list of strings and return all page numbers on which
strings appear with each page number separated by a comma;
Populate a Microsft Word template with each string's page numbers
(i.e. a template table will be created with one string on each
row and in the column beside the page numbers will be populated).
Items 1 and 3 are easy, item 2 has been destroying my brain for how to implement.
The files to be searched are most often PDFs (always file created/no need to add OCR) but occasionally include word documents.
All ideas welcome!
I am doing Copy/Paste for tables from word document to another Word document via VB.Net, but it either keeps two line in between or merge the table.
I am utilizing VB.Net in automating Word document, I am copying one formatted table from a word document, and then paste it into a different word document.
the problem here is that I have to put a "separater" between the newly pasted table and the one pasted earlier, otherwise word will merge the two (and will keep merging every single newly pasted table).
I tried to put this code before Pasting
oWord.Selection.MoveDown(Word.WdUnits.wdLine, 0)
oWord.Selection.InsertBreak(Word.WdBreakType.wdLineBreak)
oWord.Selection.PasteAndFormat(Word.WdRecoveryType.wdPasteDefault)
it worked fine but it puts two line instead of one.
appreciate if anyone give me a way to keep Pasting (or even adding new paragragh) remain always at the end of the document (with only one line-width separation)
I got a very acceptable solution
instead of using
oWord.Selection.MoveDown(Word.WdUnits.wdLine, 0)
oWord.Selection.InsertBreak(Word.WdBreakType.wdLineBreak)
oWord.Selection.PasteAndFormat(Word.WdRecoveryType.wdPasteDefault)
to insert a break, I used the following code, and it worked perfectly
With oWord.Selection
.Collapse(Direction:=Word.WdCollapseDirection.wdCollapseStart)
.InsertParagraph()
.Collapse(Direction:=Word.WdCollapseDirection.wdCollapseEnd)
End With
hope this be useful for anyone facing same problem
This question is related to my other question: Range.InsertXML using Transform
In MS Word it is easy to insert a content control using VBA, for example:
ThisDocument.ContentControls.Add wdContentControlRichText, Selection.Range
I've recently started exploring more in the XML side of things, e.g.:
Debug.Print ThisDocument.Range.XML seems to (or actually does) produce the XML for a Word document. However, if I create a NEW, BLANK document and add a Content Control I am unable to extract and reinsert the Content Control (oCC).
My steps:
added 2 blank paragraphs to a new document
added oCC to the 2nd paragraph
selected the oCC paragraph
immediate window: thisdocument.Paragraphs(1).Range.InsertXML selection.Range.XML
At first glance it LOOKS like the Content Control was duplicated, BUT on closer inspection, it was deleted and only the formatted text remains (see image, top paragraph is actually just formatted text).
Thinking I could out smart MS Word I set the properties of the Content Control to '...can not be deleted', but that didn't help.
I've also tried to insert into a separate document in case the issue had something to do with duplication of something that ought to have been unique.
In a nutshell:
To answer this question I need a way to insert a Content Control to a document using a combination of VBA and XML (or confirmation that what I am attempting is not possible).
Just realized I should use Selection.Range.WordOpenXML instead of Selection.Range.XML
I uncheck "Allow row to break across pages" for a table's properties So, the table is shown on a new page to ensure that all the content is on one page, this works fine. But Word generates a blank space before the page break, I need to replace it with some text for a legal reason. I can't use a watermark or shapes because un Oracle BI Publisher only prints it on PDF and I need to export it to a docx.
The data is dynamic, so sometimes the text before the table and the text inside the table may change.
Current Version https://imgur.com/a/FTx0q
I need some like this https://imgur.com/a/ySitL
MS Office support told me that it can't be done with Word...
Maybe with VBA code?
Update
Thanks Cindy for your help.
I have a table into another table many paragraphs, checkbox etc and they are fitting on a new page. It's working.
I understand there isn't a page break.
It's Paragraph mark.
But what I need to do is insert a kind of mark, a text like XXXX,-----------, Instead of leaving "free space",
It's a requirement not change the font size or another text format.
For a legal requirement, some paragraph must fit on a new page and "blank spaces" replaced by a kind of mark.
I can't hard code it because in several cases not all the paragraphs or section in a page will be shown and I don't know by default when a new page is needed.
I am available to use macros or anything.
What you could do is insert a page-size table into a textbox in the page header and format the body text with a white background. The table will thus be hidden behind any text on the page, but not otherwise (provided you don't pad unused space with empty paragraphs, etc.).
Is there a way to put invisible markers or id's in a document such that I can
get quick access to a fragment (paragrahp, table), in a way similar to the DIV/id combination used in HTML documents?
Yes, I can use bookmarks to point to a specific location in the document, but they do not the include the fragment itself, I'd be using two bookmarks, one to mark the start and the other for the end. Essentially what I'm looking for is a Word equivalent for named ranges as they are defined in Excel.
Any ideas?