R
RobertB.
I recorded a simple macro that opens a file, strips out page breaks, and
save the file as Unicode text in the same directory it started from.
However, I have several dozen files on which I'd like to perform the
same operation. The files all have the same file name structure, which
is "file.SFT (Word6)". The files will be saved as "file.txt".
Can I get word to open all the files in this folder, perform the find
operation and save the files without my intervention? So that I can end
up with: file1.txt, file2.txt, file3.txt (where file1, file2, file3, ...
filen represent the actual file name (before the period) found before
the conversion? Example, CODE.SFT (Word6) would become CODE.txt (a
Unicode file) and the macro will do this for all the files in a given
directory.
Is this possible?
What I recorded is:
Sub WordtoUnicode()
'
' WordtoUnicode Macro
' Macro recorded 12/10/05 by Robert
'
Documents.Open FileName:="CHEM.SFT (Word6)",
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^m"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveDocument.SaveAs FileName:="CHEM.txt", FileFormat:= _
wdFormatUnicodeText, LockComments:=False, Password:="",
AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False, HTMLDisplayOnlyOutput:=False
ActiveWindow.Close
End Sub
But obviously this will only work on the file I recorded it for. I'm
assuming I cannot simply replace the first part of the name with a wild
card.
robert
save the file as Unicode text in the same directory it started from.
However, I have several dozen files on which I'd like to perform the
same operation. The files all have the same file name structure, which
is "file.SFT (Word6)". The files will be saved as "file.txt".
Can I get word to open all the files in this folder, perform the find
operation and save the files without my intervention? So that I can end
up with: file1.txt, file2.txt, file3.txt (where file1, file2, file3, ...
filen represent the actual file name (before the period) found before
the conversion? Example, CODE.SFT (Word6) would become CODE.txt (a
Unicode file) and the macro will do this for all the files in a given
directory.
Is this possible?
What I recorded is:
Sub WordtoUnicode()
'
' WordtoUnicode Macro
' Macro recorded 12/10/05 by Robert
'
Documents.Open FileName:="CHEM.SFT (Word6)",
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^m"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
ActiveDocument.SaveAs FileName:="CHEM.txt", FileFormat:= _
wdFormatUnicodeText, LockComments:=False, Password:="",
AddToRecentFiles _
:=True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts _
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False, HTMLDisplayOnlyOutput:=False
ActiveWindow.Close
End Sub
But obviously this will only work on the file I recorded it for. I'm
assuming I cannot simply replace the first part of the name with a wild
card.
robert