![]() |
|
#1
|
|||
|
|||
|
I made a macro to do conversions on a file.
Now i have 150+ files in a folder to convert using Word (2003). Can anyboy help me to run my macro as long as there are unconverted files in my folder? TIA, Rutger |
|
#2
|
||||
|
||||
|
Hi Rutger,
What constitutes an unconverted file vs a converted file? Apart from that, the basic code for selecting a folder and looping through the Word documents in it is: Code:
Sub UpdateDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
If strFolder & "\" & strFile <> strDocNm Then
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
With wdDoc
'Do something
.Close SaveChanges:=True
End With
End If
strFile = Dir()
Wend
Set wdDoc = 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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Thanks a lot! This is exactly what I was looking for.
The only problem I have is now to save the documents, somehow they are not. I guess because the documents are .prn text files. Rutger |
|
#4
|
||||
|
||||
|
Hi Rutger
If you're opening .txt files, obviously you'd have to specify that as the type to find & open. To then save them in the Word document format, you'd need to use the SaveAs method.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| macro vba word |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Need macro to merge files in Word and preserve formatting
|
Carolin | Word VBA | 3 | 12-14-2014 04:01 AM |
| Multiple PPT files in different windows? | Caroline | PowerPoint | 0 | 04-11-2011 09:40 AM |
macro to pull data from multiple files
|
psrs0810 | Excel | 2 | 10-25-2010 01:49 PM |
| Merging Multiple Word files into One | Stattovic | Word | 0 | 01-06-2010 07:19 AM |
| Help-overwriting files-could it be macro virus? | Timpotty | Word | 0 | 03-06-2009 04:28 PM |