×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Moving to a specific tab stop

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.

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

Hi,

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
This 
   Part A
   Part B
 
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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Moving to a specific tab stop

(OP)
Components and Materials are just different variables

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

Track the length of what got put into Components and determine how many tabs are necessary.

I’ll see your silver lining and raise you two black clouds. - Protection Operations

RE: Moving to a specific tab stop

(OP)
I did add this line

CODE -->

If CompLen < 54 Then
   AddSpace = 54 - CompLen
End If 

then:

CODE -->

.InsertAfter Text:=vbTab & vbTab & Trim(Component) & Space(AddSpace) & Trim(Material) 

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

Have you tried using a fixed pitch font?

I’ll see your silver lining and raise you two black clouds. - Protection Operations

RE: Moving to a specific tab stop

(OP)
monospacing fonts are ugly...

RE: Moving to a specific tab stop

Your problem is that you are using default TAB Stops!

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Moving to a specific tab stop

...continuing.

For a line your VBA should have this sequence...

CODE

vbTab & Component & vbTab & Material & vbLf 

Or if you have a line with no component, only material...

CODE

vbTab & vbTab & Material & vbLf 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Moving to a specific tab stop

(OP)
I got it working with assigning tab stops as suggested. I'm not that familiar with word so I didn't even know you could do that.

CODE -->

wd.Selection.Paragraphs.TabStops.Add Position:=wd.InchesToPoints(1)
wd.Selection.Paragraphs.TabStops.Add Position:=wd.InchesToPoints(3.5) 

RE: Moving to a specific tab stop

Did you check out the link?

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,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Moving to a specific tab stop

(OP)
yeah... it gave me enough info to search for how to set them in VBA, thanks.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close