I am new to VBA and I hope I have posted this in the right forum.
I am trying to copy text from one opened Word document to another using a macro. In the macro I check to see if the source document is opened then move the data at each specified bookmark to another specified bookmark in the destination document.
I have two problems.
1) When I move data the narrative "FORMTEXT " appears before the added data.
2) I do not know how to move the data from a checkbox. I tried to put a bookmark in it but it's too small (or am I missing something??)
Private Sub Document_Open()
Dim strDocName As String
strDocName = "U:\Work\LHN Assessment - MASTER.doc"
If DocOpen(strDocName) = True Then
Dim appWord As Word.Application
Dim SrcDoc As Word.Document
Dim DestDoc As Word.Document
Set DestDoc = ActiveDocument
Set SrcDoc = Documents.Open("U:\Work\LHN Assessment - MASTER.doc")
' Set appWord = CreateObject("Word.Application")
'Sex'
DestDoc.Bookmarks("Text473").Range.Text = SrcDoc.Bookmarks("Text318").Range.Text
DestDoc.Bookmarks("Text487").Range.Text = SrcDoc.Bookmarks("Chk103").Range.Text
Else
MsgBox "LHN Assessment Document is closed"
End If
End Sub
I am trying to copy text from one opened Word document to another using a macro. In the macro I check to see if the source document is opened then move the data at each specified bookmark to another specified bookmark in the destination document.
I have two problems.
1) When I move data the narrative "FORMTEXT " appears before the added data.
2) I do not know how to move the data from a checkbox. I tried to put a bookmark in it but it's too small (or am I missing something??)
Private Sub Document_Open()
Dim strDocName As String
strDocName = "U:\Work\LHN Assessment - MASTER.doc"
If DocOpen(strDocName) = True Then
Dim appWord As Word.Application
Dim SrcDoc As Word.Document
Dim DestDoc As Word.Document
Set DestDoc = ActiveDocument
Set SrcDoc = Documents.Open("U:\Work\LHN Assessment - MASTER.doc")
' Set appWord = CreateObject("Word.Application")
'Sex'
DestDoc.Bookmarks("Text473").Range.Text = SrcDoc.Bookmarks("Text318").Range.Text
DestDoc.Bookmarks("Text487").Range.Text = SrcDoc.Bookmarks("Chk103").Range.Text
Else
MsgBox "LHN Assessment Document is closed"
End If
End Sub