Log in

View Full Version : Save As a File with new format and adding to the original name



Minots59
10-27-2011, 10:31 AM
Hello all,

I have this block of code here which will save my opened file as a .rft and add CH_ to the beginning of the filename. Except that when I run it, it saves the file as: CH_Normal.dotm.rtf instead of CH_"filename".rtf. Here's my code:


Sub SaveAsRTF()
Dim existingname As String
Dim stFullname As String


existingname = ThisDocument.Name

stFullname = "CH_" & existingname & ".rtf"


ActiveDocument.SaveAs filename _
:="C:\Documents and Settings\" & stFullname, FileFormat:=wdFormatRTF


End Sub

Any ideas why its changing the filename to the normal.dotm rather than keeping it the existingname?

Minots59
10-27-2011, 10:39 AM
Nevermind got it. But now its saving the file as .doc.rtf rather than .rtf so there's something I need to work on for a bit.

Tommy
10-28-2011, 06:35 AM
existingname = Replace(ThisDocument.Name,".doc","")