Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 01-09-2014, 12:00 AM
RonNCmale RonNCmale is offline Extract form fields to Word Document Windows 7 64bit Extract form fields to Word Document Office 2003
Novice
Extract form fields to Word Document
 
Join Date: Sep 2012
Posts: 15
RonNCmale is on a distinguished road
Default

Yes, I actually named it MyField to test

On the word template I have a text formfield that for the bookmark name; I named it "MyField".

Code:
Sub ProcessDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdSrcDoc As Document, wdTgtDoc As Document
Dim StrFlds As String, i As Long
StrFlds = "Form1,Form2,Form3"
strFolder = GetFolder
If strFolder = "" Then Exit Sub
Set wdTgtDoc = ActiveDocument
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  Set wdSrcDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdSrcDoc
    wdTgtDoc.Range.InsertAfter .FormFields("MyField").Result & vbCr
    .Close SaveChanges:=False
  End With
  strFile = Dir()
Wend
Set wdSrcDoc = Nothing: Set wdTgtDoc = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
I get a runtime error 5941 The requested member of the collection does not exist on

wdTgtDoc.Range.InsertAfter .FormFields("MyField").Result & vbCr

Form1, Form2, and Form3 need to be in paragraph form in sequential order on the target document
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting spreadsheet data rows as form fields in a document b3nz Word 3 03-31-2013 07:47 PM
Form Fields in Word jwm1346 Word 1 04-17-2012 07:02 PM
Extract form fields to Word Document Issues with Microsoft Word Form Fields hbforsyth Word 9 11-14-2011 04:26 PM
Calculating Form Fields in Microsoft Word wubba80 Word 1 06-25-2010 12:42 AM
Form fields in Word messed up mba Word VBA 0 02-07-2010 09:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft