|
| View previous topic :: View next topic |
| Author |
Message |
Bill Foley Guest
|
Posted: Thu Dec 20, 2007 1:10 pm Post subject: Remove specific tabstop |
|
|
I have code that goes through my document and removes all instances of a
BarTab (at 7.25 inches) and changes the RED color back to BLACK. I am
trying to modify my existing macro to just remove the current TAB on the
paragraph where my cursor lives.
My current macro is:
Sub RemoveRedLine()
' This removes the RedLines (normally when a PCN'd document is now Rev'd)
Dim Msg, Style, Title, Response
Msg = "You are about to remove all redlines! Do you want to continue?" '
Define message
Style = vbYesNo + vbDefaultButton2 ' Define buttons.
Title = "Redline Deletion" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
Application.ScreenUpdating = False
Dim oPara As Paragraph
Dim oTabStop As TabStop
For Each oPara In ActiveDocument.Paragraphs
For Each oTabStop In oPara.TabStops
If oTabStop.Position = InchesToPoints(7.25) _
And oTabStop.Alignment = wdAlignTabBar Then
oTabStop.Clear
End If
Next oTabStop
Next oPara
Selection.WholeStory
Selection.Font.Color = wdColorBlack
Selection.HomeKey Unit:=wdStory
Application.ScreenUpdating = True
Else ' User chose No.
End If
End Sub
I've tried using:
Dim oTabStop As TabStop
For Each oTabStop In Selection.Paragraphs
If oTabStop.Position = InchesToPoints(7.25) _
And oTabStop.Alignment = wdAlignTabBar Then
oTabStop.Clear
End If
Next oTabStop
It is easy to clear ALL the TABs of the current paragraph, but I just want
to clear the one at 7.25.
Any assistance would be greatly appreciated.
Bill |
|
| Back to top |
|
 |
Google Sponsor

|
Posted: Thu Dec 20, 2007 1:10 pm Post subject: Advertisement |
|
|
|
|
| Back to top |
|
 |
Klaus Linke Guest
|
Posted: Fri Dec 21, 2007 3:26 am Post subject: Re: Remove specific tabstop |
|
|
Hi Bill,
The code to remove the tab stop works fine for me.
What is it that does not work as you expect?
BTW, it might be safer not to rely on infinite precision and use something like
If Abs(oTabStop.Position - InchesToPoints(7.25)) < 1 Then
rather than
If oTabStop.Position = InchesToPoints(7.25) Then
But I doubt that's an issue in your case.
Regards,
Klaus |
|
| Back to top |
|
 |
Bill Foley Guest
|
Posted: Sat Dec 22, 2007 3:53 am Post subject: Re: Remove specific tabstop |
|
|
Klaus,
Thanks for the assistance. Sorry been out of the office (moving). I can't
remember if you helped me out with this code originally or not, but I want
to be able to remove the redline for the paragraph where the cursor is
placed. The original macro works to remove ALL redlines and BarTabs, but
the code below does not remove it for the line I am on. Not sure why...
This code here does not work. It debugs to the second line:
Dim oTabStop As TabStop
For Each oTabStop In Selection.Paragraphs
If oTabStop.Position = InchesToPoints(7.25) _
And oTabStop.Alignment = wdAlignTabBar Then
oTabStop.Clear
End If
Next oTabStop
Bill
"Klaus Linke" <info@fotosatz-kaufmann.de> wrote in message
news:%23rwLtD4QIHA.5136@TK2MSFTNGP04.phx.gbl...
Hi Bill,
The code to remove the tab stop works fine for me.
What is it that does not work as you expect?
BTW, it might be safer not to rely on infinite precision and use something
like
If Abs(oTabStop.Position - InchesToPoints(7.25)) < 1 Then
rather than
If oTabStop.Position = InchesToPoints(7.25) Then
But I doubt that's an issue in your case.
Regards,
Klaus |
|
| Back to top |
|
 |
Klaus Linke Guest
|
Posted: Sat Dec 22, 2007 6:30 pm Post subject: Re: Remove specific tabstop |
|
|
| Quote: | I can't remember if you helped me out with this code originally or not
|
Hi Bill,
I think it was about something else?
| Quote: | the code below does not remove it for the line I am on.
|
As I said, it works fine for me, removing the bar tab from the paragraph(s) in the selection (not lines, but I'm sure you are aware of that).
It does not seem to work with non-contiguous selections (... the kind you can make by selecting something, then holding down Ctrl and selecting something elsewhere) -- in that case, it only works on the last "selection".
I guessed it might fail is if the paragraphs are in a style that's set to automatically update, but I just checked and it works even then.
No idea what else might go wrong... Is there anything special (tables, text boxes, frames...)?
Is "Track changes" turned on?
You can mail me the doc, but I will be away for a few weeks soon and am not sure I'll manage to look at it before.
Regards,
Klaus |
|
| Back to top |
|
 |
Bill Foley Guest
|
Posted: Sun Dec 23, 2007 3:31 am Post subject: Re: Remove specific tabstop |
|
|
It does not work for me. Go figure. Maybe just to simplify things, what
would the code be to remove a BarTab set at 7.25 on a paragraph where your
cursor is? There might be other TABS on that same paragraph so I can't use
"ClearAll".
Bill
"Klaus Linke" <info@fotosatz-kaufmann.de> wrote in message
news:uVL7ihMRIHA.5016@TK2MSFTNGP06.phx.gbl...
| Quote: | I can't remember if you helped me out with this code originally or not
|
Hi Bill,
I think it was about something else?
| Quote: | the code below does not remove it for the line I am on.
|
As I said, it works fine for me, removing the bar tab from the paragraph(s)
in the selection (not lines, but I'm sure you are aware of that).
It does not seem to work with non-contiguous selections (... the kind you
can make by selecting something, then holding down Ctrl and selecting
something elsewhere) -- in that case, it only works on the last "selection".
I guessed it might fail is if the paragraphs are in a style that's set to
automatically update, but I just checked and it works even then.
No idea what else might go wrong... Is there anything special (tables, text
boxes, frames...)?
Is "Track changes" turned on?
You can mail me the doc, but I will be away for a few weeks soon and am not
sure I'll manage to look at it before.
Regards,
Klaus |
|
| Back to top |
|
 |
Klaus Linke Guest
|
Posted: Sun Dec 23, 2007 8:12 am Post subject: Re: Remove specific tabstop |
|
|
"Bill Foley" <billfoleyatcharterdotnet> wrote:
| Quote: | It does not work for me. Go figure. Maybe just to simplify things, what
would the code be to remove a BarTab set at 7.25 on a paragraph where your
cursor is? There might be other TABS on that same paragraph so I can't use
"ClearAll".
|
Now I'm confused
I thought that was what you are trying to do all along?
And you posted the code already:
Dim oTabStop As TabStop
For Each oTabStop In Selection.Paragraphs
If oTabStop.Position = InchesToPoints(7.25) _
And oTabStop.Alignment = wdAlignTabBar Then
oTabStop.Clear
End If
Next oTabStop
Regards,
Klaus |
|
| Back to top |
|
 |
Bill Foley Guest
|
Posted: Sun Dec 23, 2007 2:56 pm Post subject: Re: Remove specific tabstop |
|
|
Klaus,
Okay, I give up. When I use that EXACT code it fails on line 2 (For
Each...)
I will send you my file directly.
Bill
"Klaus Linke" <info@fotosatz-kaufmann.de> wrote in message
news:%23f5FbsTRIHA.3532@TK2MSFTNGP04.phx.gbl...
"Bill Foley" <billfoleyatcharterdotnet> wrote:
| Quote: | It does not work for me. Go figure. Maybe just to simplify things, what
would the code be to remove a BarTab set at 7.25 on a paragraph where your
cursor is? There might be other TABS on that same paragraph so I can't
use
"ClearAll".
|
Now I'm confused
I thought that was what you are trying to do all along?
And you posted the code already:
Dim oTabStop As TabStop
For Each oTabStop In Selection.Paragraphs
If oTabStop.Position = InchesToPoints(7.25) _
And oTabStop.Alignment = wdAlignTabBar Then
oTabStop.Clear
End If
Next oTabStop
Regards,
Klaus |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|