Need Simple VB Script to save all rtf files in a folder as docx

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Using another software to call a vb script that would open all rtf filles contained in a folder and save them as word docx files. I have a successful script that works with Excel converting xml to xlsx but am having trouble with a converting a similar
script using word. Here is my feeble attempt so far.
<span style="font-family:Courier New <font face="Courier New" style="font-family:Courier New
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 Const wdFormatDocument = 0<br/>

</font><span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 Set oWord = CreateObject("Word.Application")<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 Dim fso,f <br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 Set fso=CreateObject("Scripting.FileSystemObject")<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 Set f = fso.GetFolder("CDOutput")<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 For Each file In f.Files <br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 If Right(LCase(f.Name), 4) = ".rtf" Then<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 oWord.Open.Documents(f.Name)<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 oWord.SaveAs Left(f, Len(f) - 5) & ".docx",wdFormatDocument<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 Set f = Nothing<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 End If<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 oWord.Quit<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 Set oWord = Nothing <br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 Set fso = Nothing<br/>
<span style="font-family:Courier New; color:#800080 <span style="font-family:Courier New; color:#800080 Next<br/>
<font face="Courier New <span style="color:#800080 <br/>
I am not a VB coder but trying to figure this out by looking at examples. Any help is appreciated.</font><span style="font-family:Courier New


View the full article
 
Back
Top