![]() |
|
#1
|
||||
|
||||
![]()
The following macro allows you to browse to a folder containing the documents you want to process, then process them automatically.
Code:
Sub ProcessDocuments() Application.ScreenUpdating = False Dim strFolder As String, strFile As String, wdSrcDoc As Document, wdTgtDoc As Document 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 'Do your processing here ' .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 Code:
wdTgtDoc.Range.InsertAfter .FormFields("MyField").Result & vbCr
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#2
|
|||
|
|||
![]()
First of all, I thank you Macropod for all your help, But I can't for the life of me find out where to placed the following code.
Code:
wdTgtDoc.Range.InsertAfter .FormFields("MyField").Result & vbCr With wdSrcDoc 'Do your processing here, ' but not knowing how to code, it evidently needs more. I keep getting an error code. |
![]() |
|
![]() |
||||
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 |