Solved

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

Posted on 2016-09-18
8
48 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
Comment Utility
Have you tried

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

Open in new window

0
 

Author Comment

by:maxdbase
Comment Utility
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
Comment Utility
May be if I can inject a tab?  But how?
http://www.screencast.com/t/0Awum4A0TW
0
 
LVL 28

Expert Comment

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

Open in new window

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!

 

Author Comment

by:maxdbase
Comment Utility
FormatCurrency would work if I could make the $ flush left and the number flush right.
0
 
LVL 28

Assisted Solution

by:Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj) earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
You both rock.  I was stuck on this and your help really made a difference!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
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) …
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

743 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

8 Experts available now in Live!

Get 1:1 Help Now