Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2016-09-18
8
Medium Priority
?
109 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

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 33

Assisted Solution

by:Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj) earned 1000 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
Suggested Courses

782 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