![]() |
#1
|
|||
|
|||
![]()
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 |
|
![]() |
||||
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 |
![]() |
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 |