Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Export form data to other form in Word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
QAadmin - 04 Mar 2008 13:18 GMT
Hi everybody,
Is there a way I can import data from one Word form into another Word form?
I have a form where there is a Yes/No checkbox, and when the user checks Yes,
another form opens up. I have a code that actually does open another form,
but my problem is how to actually "link" the two, that is, the second form
should have some identification as to which form actually invoked it.
Thanks in advance.
Graham Mayor - 05 Mar 2008 12:44 GMT
Assuming a protected form with form fields the following macro will open the
other document - here called D:\My Documents\Test\Versions\Odd\Doc2.doc when
the check box Check1 is checked and writes the content of the text field
Text1 in the source document into the form field Text2 in the opened
document. Change (and add) the field and document names to suit your
requirements

Sub CopyDataToAnotherDoc()
Dim Source As Document
Dim Target As Document
Dim sField1 As String

Set Source = ActiveDocument
If Source.FormFields("Check1").CheckBox.Value = True Then
   Documents.Open FileName:="D:\My Documents\Test\Versions\Odd\Doc2.doc"
   Set Target = ActiveDocument
   sField1 = Source.FormFields("Text1").Result
   Target.FormFields("Text1").Result = sField1
End If
End Sub

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Hi everybody,
> Is there a way I can import data from one Word form into another Word
[quoted text clipped - 4 lines]
> which form actually invoked it.
> Thanks in advance.
QAadmin - 05 Mar 2008 19:48 GMT
Thank you very much Graham. I've made my adjustments, and the code worked
great. The only question I have is how to make that second form stay on top
of the first form? when I check Yes, the other forms opens up with the info
that I need in it, but it's behind the original invoking form. It's probably
a one or two lines of code, but I am not sure what...
Thank you again.

> Assuming a protected form with form fields the following macro will open the
> other document - here called D:\My Documents\Test\Versions\Odd\Doc2.doc when
[quoted text clipped - 25 lines]
> > which form actually invoked it.
> > Thanks in advance.
Graham Mayor - 06 Mar 2008 10:58 GMT
Add
Target.Activate
immediately before End If

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Thank you very much Graham. I've made my adjustments, and the code
> worked great. The only question I have is how to make that second
[quoted text clipped - 41 lines]
>>> identification as to which form actually invoked it.
>>> Thanks in advance.
QAadmin - 07 Mar 2008 13:49 GMT
Actually, I used this statement prior to posting my question, and it didn't
do the trick. But what I did was added a "Source.close" right before the
"Target.Activate" statement, and it worked I don't know how. Both files
actually stay open, with the target form on top.  But I appreciate all your
input. Thanks a lot for your help!

> Add
> Target.Activate
[quoted text clipped - 45 lines]
> >>> identification as to which form actually invoked it.
> >>> Thanks in advance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.