E
erikrthorne
I populate a word doc from an excel spreadsheet using doc variables.
This document will enventually go to a client, so I would like the
DocVariables "removed", while keeping the values themselves. similar
to a copy / pastespecial / values works in excel.
I can accomplish this manually in word by highlighting the variable,
hitting copy / paste special / unformatted text. However, when I try
to do so in VBA, it seems to simply copy back the DocVariable.
Here is the code:
set wrdApp = Word.Application
Dim myField As Field
For Each myField In ActiveDocument.Fields
Debug.Print myField.Code
myField.Result.Select
wrdApp.Selection.Copy
wrdApp.Selection.PasteAndFormat (wdFormatPlainText)
Next
Why would this work manually, but not via VBA? I've tried other
(wdFormat...) options, but with the same result.
Thanks for any help!!!
This document will enventually go to a client, so I would like the
DocVariables "removed", while keeping the values themselves. similar
to a copy / pastespecial / values works in excel.
I can accomplish this manually in word by highlighting the variable,
hitting copy / paste special / unformatted text. However, when I try
to do so in VBA, it seems to simply copy back the DocVariable.
Here is the code:
set wrdApp = Word.Application
Dim myField As Field
For Each myField In ActiveDocument.Fields
Debug.Print myField.Code
myField.Result.Select
wrdApp.Selection.Copy
wrdApp.Selection.PasteAndFormat (wdFormatPlainText)
Next
Why would this work manually, but not via VBA? I've tried other
(wdFormat...) options, but with the same result.
Thanks for any help!!!