View Single Post
  #2   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Export template field information to excel

The following is some code that runs from Access to extract information from
FormFields in all of the Word documents stored in a particular folder and
inserts it into a table in Access. You may be able to modify it to do the
same thing with Excel.

Dim dbsAQS As Database
Dim rstAQS As Recordset
Dim wordApp As Object
Dim vAuthor As String
Dim vWorkingTitle As String
Dim vStreet As String
Dim vCity As String
Dim vState As String
Dim vZip As String
Dim vPhone As String
Dim vEmail As String
Dim vWebsite As String
Dim vDateSubmitted As String
Dim vTopic As String
Dim vFormat As String
Dim vSlides As String
Dim vTransparencies As String
Dim vPhotos As String
Dim vLineDrawings As String
Dim vAuthorPhoto As String
Dim vOtherVisuals As String
Dim vSASE As String
Dim FldrPath As String
Dim RecordDoc As String
Dim Source As Object
Dim i As Long
Dim Filetokill As String

FldrPath = "C:\AQS\"

Set dbsAQS = OpenDatabase(FldrPath & "AQS.mdb")
Set rstAQS = dbsAQS.OpenRecordset("tblSources", dbOpenDynaset)

On Error GoTo CreateWordApp
Set wordApp = GetObject(, "Word.Application")
wordApp.Visible = False
On Error Resume Next



RecordDoc = Dir$(FldrPath & "*.doc")

i = 0
While RecordDoc ""
Set Source = wordApp.Documents.Open(FldrPath & RecordDoc)
vAuthor = Source.FormFields("Author").result
vWorkingTitle = Source.FormFields("WorkingTitle").result
vStreet = Source.FormFields("Street").result
vCity = Source.FormFields("City").result
vState = Source.FormFields("State").result
vZip = Source.FormFields("Zip").result
vPhone = Source.FormFields("Phone").result
vEmail = Source.FormFields("Email").result
vWebsite = Source.FormFields("Website").result
vDateSubmitted = Source.FormFields("DateSubmitted").result
vTopic = Source.FormFields("Topic").result
vFormat = Source.FormFields("Format").result
vSlides = Source.FormFields("Slides").result
vTransparencies = Source.FormFields("Transparencies").result
vPhotos = Source.FormFields("Photos").result
vLineDrawings = Source.FormFields("LineDrawings").result
vAuthorPhoto = Source.FormFields("AuthorPhoto").result
vOtherVisuals = Source.FormFields("OtherVisuals").result
vSASE = Source.FormFields("SASE").result
Filetokill = FldrPath & Source
Source.SaveAs FldrPath & "Processed\" & vAuthor
Source.Close wdDoNotSaveChanges
Kill Filetokill
With rstAQS
.AddNew
If vAuthor "" Then !Author = vAuthor
If vWorkingTitle "" Then !WorkingTitle = vWorkingTitle
If vStreet "" Then !Street = vStreet
If vCity "" Then !City = vCity
If vState "" Then !State = vState
If vZip "" Then !Zip = vZip
If vPhone "" Then !Phone = vPhone
If vEmail "" Then !Email = vEmail
If vWebsite "" Then !Website = vWebsite
If vDateSubmitted "" Then !DateSubmitted = vDateSubmitted
If vTopic "" Then !Topic = vTopic
If vFormat "" Then !Format = vFormat
If vSlides "" Then !Slides = Val(vSlides)
If vTransparencies "" Then !Transparencies = Val(vTransparencies)
If vPhotos "" Then !Photos = Val(vPhotos)
If vLineDrawings "" Then !LineDrawings = Val(vLineDrawings)
If vAuthorPhoto "" Then !AuthorPhoto = Val(vAuthorPhoto)
If vOtherVisuals "" Then !OtherVisuals = Val(vOtherVisuals)
If vSASE "" Then !SASE = Val(vSASE)
.Update
End With
i = i + 1

RecordDoc = Dir
Wend

MsgBox i & " Records Added."

Set wordApp = Nothing
Set WordDoc = Nothing

CreateWordApp:
Set wordApp = CreateObject("Word.Application")
Resume Next



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Polyanna" wrote in message
...
I have created a word form template with named bookmarks (do they need to
start with bk to be correctly named?).
How do I download information from the documents created from this form
into
excel?
I think I use the "save data for forms" checkbox but then what?