Solved

Fixed Tab

Posted on 2002-04-26
7
162 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
  • 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

860 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