Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Making a macro to edit all .doc files in a folder.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thomasanderson - 09 Feb 2006 21:24 GMT
I have a macro that edits the format and extention of a .doc file.
making it go from portrait to landscape, then change the extention from
.doc to .rft.

Now i need a macro that will automatically run the above macro for all
the .doc files in a designated folder.

Is this possible?
Graham Mayor - 10 Feb 2006 08:19 GMT
The following will open each document in a  folder change to landscape
orientation and save as RTF format,leaving the original document in the
folder also..

Sub SaveAllAsRTF()
Dim FirstLoop As Boolean
Dim myFile As String
Dim strDocName As String
Dim PathToUse As String
Dim myDoc As Document
Dim Response As Long

PathToUse = InputBox("Path To Use?", "Path", "D:\My
Documents\Test\Versions\")

On Error Resume Next
Documents.Close SaveChanges:=wdPromptToSaveChanges
FirstLoop = True
myFile = Dir$(PathToUse & "*.doc")
While myFile <> ""
   Set myDoc = Documents.Open(PathToUse & myFile)
   If FirstLoop Then
       With ActiveDocument
       Selection.PageSetup.Orientation = wdOrientLandscape
       End With
       FirstLoop = False
       Response = MsgBox("Do you want to process " & _
       "the rest of the files in this folder", vbYesNo)
       If Response = vbNo Then Exit Sub
   Else
       With ActiveDocument
       Selection.PageSetup.Orientation = wdOrientLandscape
       End With
   End If
   strDocName = ActiveDocument.FullName
   intPos = InStrRev(strDocName, ".")
   strDocName = Left(strDocName, intPos - 1)
   strDocName = strDocName & ".rtf"
   myDoc.SaveAs FileName:=strDocName, _
       FileFormat:=wdFormatRTF
   myDoc.Close SaveChanges:=wdDoNotSaveChanges
   myFile = Dir$()
Wend
End Sub

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> I have a macro that edits the format and extention of a .doc file.
> making it go from portrait to landscape, then change the extention
[quoted text clipped - 4 lines]
>
> Is this possible?

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.