PDA

View Full Version : [SOLVED] Insert after



mikke3141
10-14-2014, 05:22 AM
Hello,

I have created a bunch of word documents which are populated with excel macro. I have used bookmarks and InsertAfter.


docWord.Bookmarks("mybookmark").Range.InsertAfter "my text"

InsertAfter I have used as people can write new values on top of the bookmarks and at the same time remove accidentally the bookmark.


myresult = docWord.Bookmarks("mybookmark").Next(Unit:=wdWord, Count:=1).Range

Now I'm trying to retriew the value that was populated into the Word document, but no luck yet. How can I fix this?

Thank you for your help.

snb
10-14-2014, 06:46 AM
Use docvariables instead of bookmarks.

mikke3141
10-14-2014, 11:47 AM
Docvariables is not an option as people cannot change the value of the docvariables when entering/changing ready populated values on the document.

snb
10-14-2014, 12:04 PM
That's not correct.

mikke3141
10-14-2014, 12:40 PM
I have crated doc variables to word and populated the variables using excel
docWord.Variables("Variable1") = "Cat"

Individual opens the document and changes the visible value Cat into Dog and saves the word document. I upload the updated word document and retrieve the value.


UpdatedVariable = docWord.Variables("Variable1").Value The retrieved values is still Cat.

snb
10-15-2014, 12:38 AM
But the text in the Document is 'Dog'. Isn't the document what it is all about ?
And you may decide to unlink any docvariable any time.

mikke3141
10-15-2014, 02:30 AM
The plan is to populate mulitple word documents with the original recipient specific data (originated from excel), send the word documents to the recipients, allow the recipient to change the original data if needed, collect the documents back and import the updated information to excel for processing.

mikke3141
10-15-2014, 12:58 PM
Solved with
docWord.FormFields("Variable1").Result = "Dog"