Moving to a specific tab stop
Moving to a specific tab stop
(OP)
I'm grabbing some information from an access table and putting it into word and I'm trying to do the following:
1. Move to tabstop 2
2. insert a string, "Components" in this case
3. move to tabstop 6
4. insert a string, "Material" in this case
the issue is that "Components" varies in length and I can't just vbtab over 4 spots.. I need to go to a specific tabstop on the line... or a horizontal location.
I'm thinking that I might have to count each "Component" string and set a value of 20 (for example), and just add spaces so each "Component" is the same length... then tab over one or two spots...
any better ideas?
1. Move to tabstop 2
2. insert a string, "Components" in this case
3. move to tabstop 6
4. insert a string, "Material" in this case
the issue is that "Components" varies in length and I can't just vbtab over 4 spots.. I need to go to a specific tabstop on the line... or a horizontal location.
CODE -->
Do While Not tbl.EOF If tbl!Group = Group Then SecNum = (wd.ActiveDocument.Range(0, wd.Selection.Paragraphs(1).Range.End).Sections.Count) wd.ActiveDocument.Sections(SecNum).Range.Style = "Normal" Component = tbl!Component Material = tbl!Material With wd.Selection .InsertAfter Text:=vbTab & vbTab & Component & vbTab & vbTab & vbTab & Material .Collapse wdCollapseEnd .InsertBreak Type:=wdSectionBreakContinuous End With End If tbl.MoveNext Loop
I'm thinking that I might have to count each "Component" string and set a value of 20 (for example), and just add spaces so each "Component" is the same length... then tab over one or two spots...
any better ideas?
RE: Moving to a specific tab stop
Not sure exactly what you want to accomplish.
Rather than telling us HOW you think something might or might not happen in MS Word, how about just telling us the functional requirements of your list, like whether its a single level component list for a particular assembly or whether you have a multi-level bill-of-material or something else.
What's the difference between Components and Material?
Why, "I can't just vbtab over 4 spots"?
BTW, "4 (Tab) spots" implies 5 columns. Is that what you have?
Some lists are better presented using a fixed-pitch font like
MS Word uses TAB Stops where YOU, the user/programmer, insert the appropriate number of TAB character(s), vbTab, in the output string.
Maybe a visual example would help along with answering the above questions.
Skip,
Just traded in my OLD subtlety...
for a NUance!
RE: Moving to a specific tab stop
I hope this clears up your questions.
There will not always be all of the items in the 'components'
RE: Moving to a specific tab stop
I’ll see your silver lining and raise you two black clouds. - Protection Operations
RE: Moving to a specific tab stop
CODE -->
then:
CODE -->
but it doesn't work out, even if I add a vbtab after i add the spaces. The reason, I believe, is, for example:
Heads = 5 characters
Shell = 5 characters
... but they don't line up the same and there is actually an additional two space in Heads vs Shell.. because the two 'l's
RE: Moving to a specific tab stop
I’ll see your silver lining and raise you two black clouds. - Protection Operations
RE: Moving to a specific tab stop
RE: Moving to a specific tab stop
For the example you posted, you should have 2 and only 2 TAB Stops:
Stop 1 at the position you want Components
Stop 2 at the position you want Material
That will work for proportional or mono spaced fonts.
Check out...
https://www.officetooltips.com/word_365/tips/tabs_...
Skip,
for a NUance!
RE: Moving to a specific tab stop
For a line your VBA should have this sequence...
CODE
Or if you have a line with no component, only material...
CODE
Skip,
for a NUance!
RE: Moving to a specific tab stop
CODE -->
RE: Moving to a specific tab stop
It explains all about clearing and setting TAB Stops.
So you got your document formatted to work As Expected.
(Aside)
There's
As Expected (As Envisioned)
As Designed
As Planned
As Built
As Modified
As Maintained
(**wink**)
Skip,
for a NUance!
RE: Moving to a specific tab stop