View Full Version : Form fields from one word document to another
gibbo1715
10-14-2006, 08:30 AM
Afternoon All
I have two word documents bot with the form field txtName,
What i want to do is copy the txtname from a closed document into my open document from my open document
can anyone point me in the right direction please
thanks
gibbo
gibbo1715
10-14-2006, 08:47 AM
Sorry All
Just realised I figured this out for something similar the other day
Code below will work
Private Sub CommandButton1_Click()
'---------------------------------------------------------------------------
Dim Folder As Object
Dim Files As Object
Dim file As Object
Dim fldr
Dim AppWrd As New Word.Application
Dim Doc As Word.Document
Dim FileName As String
Dim test As String
On Error Resume Next
Set Doc = AppWrd.Documents.Open(FileName:="C:\test.doc", ReadOnly:=True, _
PasswordDocument:="")
test = Doc.FormFields("txtName").Result
Doc.Close False
Set Doc = Nothing
Set AppWrd = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
ActiveDocument.FormFields("txtName").Result = test
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.