J
jag
Hello all,
Having a problem coping data from one document to another. I need to
automate the following task. I have a document that my customer opens and
clicks a button that does a copy. When the button is clicked, I need the
following to happen.
The file open dialog box displays so they can pick the file that has data to
be copied from
The selected file is opened
Data from an enclosed bookmark in the newly opened file is copied
The data is then pasted to a bookmark location in the intial document
I have this working, the problem is when I do the past into the initial
document, it deletes all the text in the document and then paste the new
text.
What am I doing wrong?? I needed to be sure the copied data retains all
formatting, like bullet list, etc. My code is listed below.
thanks
Sub Copy_Description()
Dim DescriptionDoc As Document
Dim pTarget As Range
Dialogs(wdDialogFileOpen).Show
Set DescriptionDoc = ActiveDocument
Set pTarget =
ActiveDocument.Bookmarks("BM_TheDescription").Range.FormattedText
pTarget.Copy
If ThisDocument.Bookmarks.Exists("BM_Description") Then
ThisDocument.Bookmarks("BM_Description").Select
ThisDocument.Range.Paste
End If
ActiveDocument.Close
End Sub
Having a problem coping data from one document to another. I need to
automate the following task. I have a document that my customer opens and
clicks a button that does a copy. When the button is clicked, I need the
following to happen.
The file open dialog box displays so they can pick the file that has data to
be copied from
The selected file is opened
Data from an enclosed bookmark in the newly opened file is copied
The data is then pasted to a bookmark location in the intial document
I have this working, the problem is when I do the past into the initial
document, it deletes all the text in the document and then paste the new
text.
What am I doing wrong?? I needed to be sure the copied data retains all
formatting, like bullet list, etc. My code is listed below.
thanks
Sub Copy_Description()
Dim DescriptionDoc As Document
Dim pTarget As Range
Dialogs(wdDialogFileOpen).Show
Set DescriptionDoc = ActiveDocument
Set pTarget =
ActiveDocument.Bookmarks("BM_TheDescription").Range.FormattedText
pTarget.Copy
If ThisDocument.Bookmarks.Exists("BM_Description") Then
ThisDocument.Bookmarks("BM_Description").Select
ThisDocument.Range.Paste
End If
ActiveDocument.Close
End Sub