PDA

View Full Version : import text from another document, paste into form field result



OTWarrior
09-18-2007, 06:00 AM
I have a word document with form fields that the user will enter information into. This document is protected.
The information the user inputs into this form is also held in another document, and I have had people "comment" on having to enter information twice.

So I came up with the idea of importing the data from this other document into my document. The first problem is actually importing the information from the document itself:


Private Sub cmdImport_Click()
Dim MyFile As String
ActiveDocument.Bookmarks("ImportTest").Select
MyFile = Dir("W:\Test Documents\")
Selection.InsertFile FileName:=MyFile & "test.doc"
End Sub

The above code specifically imports the contents of the file and pastes them into the document. Whereas I would Ideally want the information to be brought into a string value for me to manipulate.

The other issue with this code, is this is very specific, and you cannot choose the file or directory. How would I bring open an explorer dialog box (like when you press "insert|file...").

the full explaination of what I want to do is to import the first page from this document, search for certain words (as the author did not use bookmarks or form fields) and import the certain words into my chosen form fields as the result value.

Just some help with how to use a dialog box to choose the file, and how to bring the information in without pasting it onto the document would be very much appreciated.

(BTW: I cannot use any databases or change the document that I want to import from)

mdmackillop
09-19-2007, 12:17 PM
Here's somthing rough and ready using bookmarks.
Select text and clicjk a small button to insert it against a bookmark. Write insets the text in the bookmark.

OTWarrior
09-20-2007, 12:50 AM
The functionailty is kinda what I want, and is a very good step in the right direction.

However, I will need to not have it as a userform, and to make to more automatic, but it does give me a great head start. Thank you.:)