Solved

vb script microsoft word table cell: inject flush left dollar sign

Posted on 2016-09-18
8
62 Views
Last Modified: 2016-09-18
How can I change this code so that ther is a flush left $ sign in the table cell as in the screenshot:

dim myval
myval = 19298888
tbl.cell(2,9).range.text= FormatNumber(myval)

Screenshot: http://www.screencast.com/t/te3vRJMd0
0
Comment
Question by:maxdbase
  • 4
  • 2
  • 2
8 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 41803766
Have you tried

tbl.cell(2,9).range.text= "$" & FormatNumber(myval)

Open in new window

0
 

Author Comment

by:maxdbase
ID: 41803787
No, I will try it.
Will it make the $ flush left and the FormatNumber(myval) flush right?
I think I need something in between that will do that.
0
 

Author Comment

by:maxdbase
ID: 41803789
May be if I can inject a tab?  But how?
http://www.screencast.com/t/0Awum4A0TW
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
LVL 29

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41803792
Have you tried something like this?
tbl.cell(2, 9).Range.Text = FormatCurrency(myval)

Open in new window

0
 

Author Comment

by:maxdbase
ID: 41803806
FormatCurrency would work if I could make the $ flush left and the number flush right.
0
 
LVL 29

Assisted Solution

by:Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj) earned 250 total points
ID: 41803811
You may also try something like below to see if that works for you...

tbl.Cell(2, 9).Range.Text = "$" & vbTab & FormatNumber(myval)

Open in new window

0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
ID: 41803881
Ah, I see. In that case Subodh Tiwari has the right idea, but you need  a right-justified tabstop at the right hand end of the cell:
    With tbl.Cell(2, 9)
        .Range.Text = "$" & vbTab & FormatNumber(myval)
        .Range.ParagraphFormat.TabStops.Add Position:=cl.Width - .RightPadding - .LeftPadding _
            , Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
    End With
0
 

Author Closing Comment

by:maxdbase
ID: 41803961
You both rock.  I was stuck on this and your help really made a difference!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

785 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