Solved

Fixed Tab

Posted on 2002-04-26
7
159 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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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_
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 3

Author Comment

by:andysalih
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
cheers, workd great

Andy
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now