Solved

Fixed Tab

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

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2003, my txt file export is running backwards 4 46
Adding to a VBA? 6 61
vb6 connector to mongodb 2 49
Prevent user closing word document opened with VB6 6 67
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

920 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

15 Experts available now in Live!

Get 1:1 Help Now