Solved

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

Posted on 2016-09-18
8
96 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 31

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 31

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

615 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