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
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
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
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.C learAll
ActiveDocument.DefaultTabS top = 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.A dd Position:=InchesToPoints(0 .4), Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
'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.
ActiveDocument.DefaultTabS
Selection.TypeText Text:=vbTab & "Blah Blah" & vbCrLf
'This will allow you to set tabs on a line at different distances
Selection.ParagraphFormat.
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes thats correct elmo.
I will try your code this week and give it a try,
will be back to score
cheers
Andy
I will try your code this week and give it a try,
will be back to score
cheers
Andy
ASKER
cheers, workd great
Andy
Andy
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