Link to home
Start Free TrialLog in
Avatar of andysalih
andysalih

asked on

Fixed Tab

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
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

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
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
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

Avatar of andysalih
andysalih

ASKER

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  
ASKER CERTIFIED SOLUTION
Avatar of Elmo_
Elmo_
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes thats correct elmo.

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

will be back to score

cheers

Andy
cheers, workd great

Andy