Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default how to I import word form fields in excel

I have created a word form which will be completed by several users. How do
I import specific fields from completed forms into excel.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default how to I import word form fields in excel

Hi Richard,

Hope this helps. It is a little sample of both writing to word document
variables and getting the values from them.

Sub Get_DocVariable()

Dim PathFileName
Dim objWord
Dim Variable1
Dim Variable2

PathFileName = CurDir & "\" & "DocVariable Copy Test.doc"

Set objWord = CreateObject("Word.Application")

With objWord
.Documents.Open PathFileName
.Visible = True

'Write data to a Word document DocVariable
.ActiveDocument.Variables("MyDocVariable1") = "Data in my first Variable"
.ActiveDocument.Variables("MyDocVariable2") = "Data in my Second Variable"

'Get data from a Word document DocVariable
Variable1 = .ActiveDocument.Variables("MyDocVariable1")
Variable2 = .ActiveDocument.Variables("MyDocVariable2")
End With

MsgBox "MyDocVariable1 = " & Variable1 & Chr(13) & _
"MyDocVariable1 = " & Variable2


End Sub


--
Regards,

OssieMac


"Richard" wrote:

I have created a word form which will be completed by several users. How do
I import specific fields from completed forms into excel.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default how to I import word form fields in excel

Hi again Richard,

I think that my answer is probably misleading for what you want to achieve.
I assume that your word document has FormText fields for the user to insert
data and the example does not work on them.

--
Regards,

OssieMac


"OssieMac" wrote:

Hi Richard,

Hope this helps. It is a little sample of both writing to word document
variables and getting the values from them.

Sub Get_DocVariable()

Dim PathFileName
Dim objWord
Dim Variable1
Dim Variable2

PathFileName = CurDir & "\" & "DocVariable Copy Test.doc"

Set objWord = CreateObject("Word.Application")

With objWord
.Documents.Open PathFileName
.Visible = True

'Write data to a Word document DocVariable
.ActiveDocument.Variables("MyDocVariable1") = "Data in my first Variable"
.ActiveDocument.Variables("MyDocVariable2") = "Data in my Second Variable"

'Get data from a Word document DocVariable
Variable1 = .ActiveDocument.Variables("MyDocVariable1")
Variable2 = .ActiveDocument.Variables("MyDocVariable2")
End With

MsgBox "MyDocVariable1 = " & Variable1 & Chr(13) & _
"MyDocVariable1 = " & Variable2


End Sub


--
Regards,

OssieMac


"Richard" wrote:

I have created a word form which will be completed by several users. How do
I import specific fields from completed forms into excel.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default how to I import word form fields in excel

Hi yet again Richard,

After my previous effort which I now think was not what you are looking for
I felt bound to have another look at the problem and perhaps the following
might help.

It does assume that you are using FormText fields for the user to complete
with the form protected. If the form is not protected when the user fills in
the data, the field names disappear.

You then need to unprotect the document to run the code or it cannot select
the data.

If anyone has a better answer then feel free to post it because I am also
interested.

Sub Get_FormText()

Dim PathFileName
Dim objWord
Dim Variable1
Dim Variable2

PathFileName = CurDir & "\" & "DocVariable Copy Test.doc"

Set objWord = CreateObject("Word.Application")

With objWord
.Documents.Open PathFileName
.Visible = True

'Get data from a Word document DocVariable
.ActiveDocument.bookmarks("Text1").Select
Variable1 = .Selection
.ActiveDocument.bookmarks("Text2").Select
Variable2 = .Selection
End With

MsgBox "Text1 = " & Variable1 & Chr(13) & _
"Text2 = " & Variable2


End Sub


--
Regards,

OssieMac


"OssieMac" wrote:

Hi again Richard,

I think that my answer is probably misleading for what you want to achieve.
I assume that your word document has FormText fields for the user to insert
data and the example does not work on them.

--
Regards,

OssieMac


"OssieMac" wrote:

Hi Richard,

Hope this helps. It is a little sample of both writing to word document
variables and getting the values from them.

Sub Get_DocVariable()

Dim PathFileName
Dim objWord
Dim Variable1
Dim Variable2

PathFileName = CurDir & "\" & "DocVariable Copy Test.doc"

Set objWord = CreateObject("Word.Application")

With objWord
.Documents.Open PathFileName
.Visible = True

'Write data to a Word document DocVariable
.ActiveDocument.Variables("MyDocVariable1") = "Data in my first Variable"
.ActiveDocument.Variables("MyDocVariable2") = "Data in my Second Variable"

'Get data from a Word document DocVariable
Variable1 = .ActiveDocument.Variables("MyDocVariable1")
Variable2 = .ActiveDocument.Variables("MyDocVariable2")
End With

MsgBox "MyDocVariable1 = " & Variable1 & Chr(13) & _
"MyDocVariable1 = " & Variable2


End Sub


--
Regards,

OssieMac


"Richard" wrote:

I have created a word form which will be completed by several users. How do
I import specific fields from completed forms into excel.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import text from Word Form to Excel CBER Excel Discussion (Misc queries) 1 September 13th 07 04:52 PM
Excel to input fields into a Word Form ArmsteR Excel Worksheet Functions 1 August 3rd 07 09:16 AM
How to Transfer data from Text Form Fields in MS Word into Excel? CWillis Excel Discussion (Misc queries) 1 July 18th 06 06:35 AM
Put form fields in Word forms into an Excel spreadsheet? AMG Excel Discussion (Misc queries) 4 May 15th 06 06:18 AM
can we link fields from a form in word document to excel Sunil Excel Discussion (Misc queries) 0 February 6th 06 09:26 PM


All times are GMT +1. The time now is 03:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"