G
Gillette Kempf
I want to rename Word's built-in style names to remove the spaces
(this will assist in importing documents into RoboHelp). I found a
nifty post with macro by Klaus Linke dated 04-12-2002 -- however only
the first part of the macro is working. I am not a VBA expert, so I am
not sure what is missing from the code. If anyone can assist with
this I would appreciate it.
Sub ChangeStyleNames()
' The macro appends a * to all style names
' It thus changes built-in styles to ordinary styles
Dim myRange As Range
Dim MsgText
Dim myFileName
MsgText = "Cancel if you have not saved the file"
If MsgBox(MsgText, vbExclamation + vbOKCancel, _
"Danger") = vbCancel Then
End
End If
myFileName = ActiveDocument.Name
If InStr(1, myFileName, ".") > 0 Then
myFileName = Left$(myFileName, _
InStr(1, myFileName, ".")) & "RTF"
Else
myFileName = myFileName & ".RTF"
End If
ActiveDocument.SaveAs _
FileName:=myFileName, _
FileFormat:=wdFormatRTF
ActiveDocument.Close
<<I believe this is the point at which the macro stops working>>
Documents.Open _
FileName:=myFileName, _
ConfirmConversions:=False, _
Format:=wdOpenFormatText
Set myRange = ActiveDocument.Content
myRange.Find.Execute _
FindText:="\{\\stylesheet*\}\}", _
MatchWildcards:=True
myRange.Find.Execute _
FindText:=";\}", _
ReplaceWith:="*^&", _
MatchWildcards:=True, _
Replace:=wdReplaceAll
ActiveDocument.Save
ActiveDocument.Close
Documents.Open _
FileName:=myFileName
End Sub
Thanks again for all the assistance I have received at various times
from the great people on this list <g>.
Gillette
(this will assist in importing documents into RoboHelp). I found a
nifty post with macro by Klaus Linke dated 04-12-2002 -- however only
the first part of the macro is working. I am not a VBA expert, so I am
not sure what is missing from the code. If anyone can assist with
this I would appreciate it.
Sub ChangeStyleNames()
' The macro appends a * to all style names
' It thus changes built-in styles to ordinary styles
Dim myRange As Range
Dim MsgText
Dim myFileName
MsgText = "Cancel if you have not saved the file"
If MsgBox(MsgText, vbExclamation + vbOKCancel, _
"Danger") = vbCancel Then
End
End If
myFileName = ActiveDocument.Name
If InStr(1, myFileName, ".") > 0 Then
myFileName = Left$(myFileName, _
InStr(1, myFileName, ".")) & "RTF"
Else
myFileName = myFileName & ".RTF"
End If
ActiveDocument.SaveAs _
FileName:=myFileName, _
FileFormat:=wdFormatRTF
ActiveDocument.Close
<<I believe this is the point at which the macro stops working>>
Documents.Open _
FileName:=myFileName, _
ConfirmConversions:=False, _
Format:=wdOpenFormatText
Set myRange = ActiveDocument.Content
myRange.Find.Execute _
FindText:="\{\\stylesheet*\}\}", _
MatchWildcards:=True
myRange.Find.Execute _
FindText:=";\}", _
ReplaceWith:="*^&", _
MatchWildcards:=True, _
Replace:=wdReplaceAll
ActiveDocument.Save
ActiveDocument.Close
Documents.Open _
FileName:=myFileName
End Sub
Thanks again for all the assistance I have received at various times
from the great people on this list <g>.
Gillette