Solved

Fixed Tab

Posted on 2002-04-26
7
165 Views
Last Modified: 2010-05-02
does anybody know how to use fixed tab positioning in code eg.

selection.typetext = "blah blah")

I would like to print that at tab 10 all the time within a word document.

i dont want to be doing this :0

selection.typetext = "blah blah" & chr(10)

because if the word blah blah becomes blah then I would need to calculate and re-add the amount of tabs.

i just want to print at a fixed tab

any ideas ??

cheers
andy

this needs to work in VBA
0
Comment
Question by:andysalih
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6971136
I guess you are looking for the Right-Fixed tab.
In Word, you can use tabs where the text gets right-aligned, so you don't need to calculate whatsoever.
If you need more help....
CHeers
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6971139
BTW, i have seen that you have several (quite) old questions open... Would you please mind to keep them updated and closed if possible.

CHeers
0
 
LVL 3

Expert Comment

by:Elmo_
ID: 6971165
This might help.

'What this does here is set the default tab stop to .5 of an inch.  The vbtab inserts a tab, then add your text and a return character to get to the next line.
Selection.ParagraphFormat.TabStops.ClearAll
ActiveDocument.DefaultTabStop = InchesToPoints(0.5)
Selection.TypeText Text:=vbTab & "Blah Blah" & vbCrLf

'This will allow you to set tabs on a line at different distances
Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(0.4), Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces

0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 3

Author Comment

by:andysalih
ID: 6971303
Thanks for that but that will not work

lets say this is what i want

if the text below is written out to word i would like the format to read

xx         xxxxxxxxxx
xxxxxx     xxxxxxxxxx
xxxx       xxxxxxxxxx
xxxxxxxxx  xxxxxxxxxx
xxx        xxxxxxxxxx
xxxxxxxxxx xxxxxxxxxx

BUT INSTEAD I GET THIS
x          xxxxxxxxxx
xxxxxx            xxxxxxxxxxxxxx
xxxx       xxxxxxxxxx
xxxxxxxxxx        xxxxxxxxxxxxxx
xxxx       xxxxxxxxxx
xxxxxxxxxx        xxxxxxxxxxxxxx

this is because of the string length is longer and then sets the tab from after the string instead of the tab being fixed.

god this is hard to explain

does that make much sence ???

cheers

andy  
0
 
LVL 3

Accepted Solution

by:
Elmo_ earned 180 total points
ID: 6971510
Andy,

I take it that you basically want two columns of data.

Where the start of each column entry is aligned vertically with the preceding one.

Will you try entering this code into a word macro and Run it from there and tell me if I am even on the same track as you?

Sub Test()
Dim S1 As String
Dim S2 As String
Dim S3 As String

    S1 = "Hello There"
    S2 = "Andy"
   
    'Set the Default Tab
    ActiveDocument.DefaultTabStop = InchesToPoints(0.75)
   
    S3 = S1 & vbTab & S2 & vbCrLf
    Selection.TypeText Text:=S3
   
    S3 = S2 & vbTab & S1 & vbCrLf
    Selection.TypeText Text:=S3
   
End Sub

Cheers,

Ed.
0
 
LVL 3

Author Comment

by:andysalih
ID: 6980125
yes thats correct elmo.

I will try your code this week and give it a try,

will be back to score

cheers

Andy
0
 
LVL 3

Author Comment

by:andysalih
ID: 6985987
cheers, workd great

Andy
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question