D
DWTSG
Word XP
This macro flushes right selected text
Sub FlushRight()
If Selection.Range.Text = "" Then
MsgBox ("You must select the text you want to flush right")
Else
'Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6), _
' Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
Dim iTabStop As Integer
With ActiveDocument.PageSetup
iTabStop = .PageWidth - .LeftMargin - .RightMargin
End With
Selection.ParagraphFormat.TabStops.Add Position:=iTabStop, _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
Selection.Copy
Selection.TypeText Text:=vbTab
Selection.Paste
Selection.TypeParagraph
End If
End Sub
all of a sudden it does not work in headers or footers, it functions
flawlessly every where else. Could you please take a look at the code and
see if you notice anything strange. The error I get is at the
selection.copy portion, I get an error telling me that this method is not
available because no text is selected, I can assure you that I do indeed
have text selected. If I run the macro in a header and footer without
selecting any text I get my msgbox warning. If I select the text I get the
vba error. Thanks in advance for the help.
Jim
This macro flushes right selected text
Sub FlushRight()
If Selection.Range.Text = "" Then
MsgBox ("You must select the text you want to flush right")
Else
'Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6), _
' Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
Dim iTabStop As Integer
With ActiveDocument.PageSetup
iTabStop = .PageWidth - .LeftMargin - .RightMargin
End With
Selection.ParagraphFormat.TabStops.Add Position:=iTabStop, _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
Selection.Copy
Selection.TypeText Text:=vbTab
Selection.Paste
Selection.TypeParagraph
End If
End Sub
all of a sudden it does not work in headers or footers, it functions
flawlessly every where else. Could you please take a look at the code and
see if you notice anything strange. The error I get is at the
selection.copy portion, I get an error telling me that this method is not
available because no text is selected, I can assure you that I do indeed
have text selected. If I run the macro in a header and footer without
selecting any text I get my msgbox warning. If I select the text I get the
vba error. Thanks in advance for the help.
Jim