Hi there,

I made a macro to convert a text file into a RTF file with a desired format.
But it stops after it converts and saves a current file. In other words, one
click of macro runs for each opened file. It must have some ways to do one
click for multiple opened files conversion. Any suggestions or recommeded
articles or codes?

Thanks,

Re: How to run a macro multiple times by one click by Doug

Doug
Sun May 18 12:28:15 PDT 2008

See the article "Find & ReplaceAll on a batch of documents in the same
folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

You could modify that so that it incorporates your routine rather than doing
the Find and Replace.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"sfp" <sfp@discussions.microsoft.com> wrote in message
news:5C3FAC9D-2537-4008-9648-61CB6298E7E9@microsoft.com...
> Hi there,
>
> I made a macro to convert a text file into a RTF file with a desired
> format.
> But it stops after it converts and saves a current file. In other words,
> one
> click of macro runs for each opened file. It must have some ways to do one
> click for multiple opened files conversion. Any suggestions or recommeded
> articles or codes?
>
> Thanks,
>
>



Re: How to run a macro multiple times by one click by Graham

Graham
Sun May 18 22:23:17 PDT 2008

The following will save all the doc files in a folder as RTF

Sub SaveAllAsRTF()
Dim strFileName As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document
Dim Response As Long
Dim fDialog As FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , "Save all as RTF"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If

strFileName = Dir$(strPath & "*.doc")

While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)

strDocName = ActiveDocument.FullName
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".rtf"
oDoc.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatRTF
oDoc.Close SaveChanges:=wdDoNotSaveChanges
strFileName = Dir$()
Wend
End Sub


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

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


sfp wrote:
> Hi there,
>
> I made a macro to convert a text file into a RTF file with a desired
> format. But it stops after it converts and saves a current file. In
> other words, one click of macro runs for each opened file. It must
> have some ways to do one click for multiple opened files conversion.
> Any suggestions or recommeded articles or codes?
>
> Thanks,