Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-07-2014, 06:55 PM
RonNCmale RonNCmale is offline Extract form fields to Word Document Windows XP 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 Extract form fields to Word Document

The following code works, but I need to tweak this to do the following.
1.Word documents that are in folder are protected w/o password, need this macro to unprotect and then retrieve data.
2. Would like macro to be able to retrieve a form field by bookmark name
instead of all form fields.

Any help would be appreciated.



Code:
Dim mydoc As Document
Dim target As Document
Dim i As Long

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() <> -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path
Set target = Documents.Add
If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If
'get files from the selected path
'and insert them into the doc
 MyName = Dir$(MyPath & "*.*")
 Do While MyName <> ""
 Set mydoc = Documents.Open(MyPath & MyName)
For i = 1 To mydoc.FormFields.Count - 1
 target.Range.InsertAfter mydoc.FormFields(i).Result & vbTab
 Next i
target.Range.InsertAfter mydoc.FormFields(i).Result & vbCr
 mydoc.Close wdDoNotSaveChanges
 MyName = Dir$
 Loop

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 12:17 PM.


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