Graham
Mon Jul 14 07:16:09 PDT 2008
Is the macro in the document that Word closes? Put it in your normal
template - see
http://www.gmayor.com/installing_macro.htm
Do the documents in the folder have the extension doc? The macro only works
with doc files as written.
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site
http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Ted wrote:
> I copied the text and created a new macro in a new document. When I
> run the macro it does prompt me for the folder location, but when I
> click ok it doesn't do anything. It closes the document and doesn't
> resave allt he files in the folder. I'm not sure what I am doing
> wrong. Any help would be greatly appreciated.
>
> "Graham Mayor" wrote:
>
>> Rather than mess up the add-in - use the following macro to batch
>> save all the documents as TXT
>>
>> Sub SaveAllAsTXT()
>> 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 TXT"
>> 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 & ".txt"
>> oDoc.SaveAs FileName:=strDocName, _
>> FileFormat:=wdFormatDOSText
>> 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
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>> Ted wrote:
>>> I understand that and did try to modify the code before posting but
>>> couldn't get it to do what I wanted. I am not that good with code
>>> which is why I posted the question here.
>>>
>>> "Doug Robbins - Word MVP" wrote:
>>>
>>>> You could modify the code to do that.
>>>>
>>>> --
>>>> 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
>>>>
>>>> "Ted" <Ted@discussions.microsoft.com> wrote in message
>>>> news:25406A91-B5BA-4427-B7B9-7CB405AC8217@microsoft.com...
>>>>> This is perfect, thank you. I was wondering if there is a way to
>>>>> have it save
>>>>> each of the separate documents with a different extension like a
>>>>> basic .txt
>>>>> file.
>>>>>
>>>>> "Graham Mayor" wrote:
>>>>>
>>>>>> See
http://www.gmayor.com/individual_merge_letters.htm
>>>>>>
>>>>>> --
>>>>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>>>> Graham Mayor - Word MVP
>>>>>>
>>>>>> My web site www.gmayor.com
>>>>>> Word MVP web site
http://word.mvps.org
>>>>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>>>>
>>>>>>
>>>>>> Ted wrote:
>>>>>>> I have a mail merge document and need a macro or script that
>>>>>>> will go through all the mail merge records and save each record
>>>>>>> as it's own document using one of the mail merge fields as the
>>>>>>> document name. Is this possible?