J
Jared Goralnick
I've written a pretty neat set of macros that automatically create
underlines and form fields that a user of the form can then type over
without affecting the underlines...as it's such a pain to teach the
form developers how to work with them and it's also a rather tedious
process. But I have hit a roadblock...
I need to be able to programmatically change all the default tabstops
that are being used in a given line to custom tabstops. So for
instance, if the form developer pressed the tab key without setting a
custom tabstop for it and then ran one of my macros, things would get
all messed up as the tab they previously used would move to one of the
custom tabstops set by my macro. I think I have the process down, but
my VBA knowledge of how to do it is somewhat limited. So please let
me know if you can fill in any of the blanks... Here's what I have:
Sub ChangeDefaultTabstopsToCustoms()
' Need to find a way to get the current line in my range and then
' be able to place my selection at my previous cursor position
Dim rCurrentLine As Range
rCurrentLine = Selection. '??
' Need to put all the below stuff in a while loop, as it'll repeat
' while the find operation below still finds a new tab
' With the current line I need to start at its beginning char and
' search forward to see if there are any tab characters.
With rCurrentLine.Find
.ClearFormatting
.text = "^t"
.Forward = True
.ClearFormatting
End With
rCurrentLine.Find.Execute
' Now that I've found a tab, I need to find out it's location and
' if it applies to a custom tab or not. I think this is a two step
' process of finding it's location with the
' currentTab.Information(wdHorizontalPositionRelativeToTextBoundary
' property (divided by 72). Then cycling through my tabstops to find
' a tabstop at that location and see if it's a default or custom one,
' which is merely a matter of
' If TabStops(x).CustomTab
' and then setting it if not:
' .TabStops.Add Position:=InchesToPoints(dCurrentPosInInches), _
' Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
'
End Sub
Pain the butt, eh? I don't think this is rocket science, I'm just
missing some pieces. This'd be a useful macro for the net's
repertoire. Any help would be much appreciated!
Thanks!
Jared
underlines and form fields that a user of the form can then type over
without affecting the underlines...as it's such a pain to teach the
form developers how to work with them and it's also a rather tedious
process. But I have hit a roadblock...
I need to be able to programmatically change all the default tabstops
that are being used in a given line to custom tabstops. So for
instance, if the form developer pressed the tab key without setting a
custom tabstop for it and then ran one of my macros, things would get
all messed up as the tab they previously used would move to one of the
custom tabstops set by my macro. I think I have the process down, but
my VBA knowledge of how to do it is somewhat limited. So please let
me know if you can fill in any of the blanks... Here's what I have:
Sub ChangeDefaultTabstopsToCustoms()
' Need to find a way to get the current line in my range and then
' be able to place my selection at my previous cursor position
Dim rCurrentLine As Range
rCurrentLine = Selection. '??
' Need to put all the below stuff in a while loop, as it'll repeat
' while the find operation below still finds a new tab
' With the current line I need to start at its beginning char and
' search forward to see if there are any tab characters.
With rCurrentLine.Find
.ClearFormatting
.text = "^t"
.Forward = True
.ClearFormatting
End With
rCurrentLine.Find.Execute
' Now that I've found a tab, I need to find out it's location and
' if it applies to a custom tab or not. I think this is a two step
' process of finding it's location with the
' currentTab.Information(wdHorizontalPositionRelativeToTextBoundary
' property (divided by 72). Then cycling through my tabstops to find
' a tabstop at that location and see if it's a default or custom one,
' which is merely a matter of
' If TabStops(x).CustomTab
' and then setting it if not:
' .TabStops.Add Position:=InchesToPoints(dCurrentPosInInches), _
' Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
'
End Sub
Pain the butt, eh? I don't think this is rocket science, I'm just
missing some pieces. This'd be a useful macro for the net's
repertoire. Any help would be much appreciated!
Thanks!
Jared