PPT VBA Format(Adollar, "$ #,##0.00")

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In PowerPoint I used the Format() function to format a number. Unknown to me
at the time the reference library Microsoft Windows CommonControls-26.0 (SP4)
is not available (missing) on most other computers. I do not want the users
of the presentation to have to download the library either. Unless there is
a way to package and install it automatically which due to my lack of
knowledge seems a bit too complex.

So, instead of re-inventing the wheel I was hoping that I can find some code
that I could modify for my use.

This is what I am trying to do:

User inputs a number:

2500

PPT VBA code formats it to:

$2,500.00

This was the code I used before

Private Sub txtBx_value_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
txtBx_value.Text = Format(txtBx_value.Text, "$ #,##0.00")
End Sub



My logic is to write code that counts the number of characters (places) in
the number using Len() then loop through looking for the decimal point,
commas if entered etc. and place the commas, decimal point and commas in the
appropriate place.

Thanks in advance for any help you offer…
 
I'm a bit confused. Format, as you use it here, is intrinsic to VBA.
No add'l controls are needed.

What object's .Text property are you working with here?
 
Sorry I am new at this. So, I am not sure of the text property.

This is the code I am using

TextBox1.Text = Format(txtBx_value.Text, "$ #,##0.00")

Which worked fine on my computer XP professional PPT 2002 SP3 but it did not
work on two other computers. There was a compile error: Can't find project
or library.

1 computer was running PowerPoint 2003 and My laptop was running XP Pro with
PowerPoint 2000. When I went to tools reference on My laptop (non-working
computers) it said that Missing "Microsoft Windows CommonControls-26.0 (SP4)"

Per Microsoft the problem is the missing "Microsoft Windows
CommonControls-26.0 (SP4)" and they gave me a link to download the control.
I might have lead the Microsoft guy to this conclusion due to my asking if
this was the problem and he took the easy way out by agreeing and giving me a
link to download. I did not load Microsoft Windows CommonControls-26.0 (SP4)
to my laptop to see if this was the correct problem.

I hope this answers your question. Thanks for your help.
 
Update: More Info

recap: I send a client a PPT with a userform. It keep crashing on him. But
it worked on my developing computer. I tested it on my laptop and had the
same problem as the client. I isolated the problem to format() and chr() not
being recognized. By taking these out of my code the Userform worked without
causing errors on my laptop and the client's computer.

On my laptop format() does not work in ML.ppt but if I open a new PPT and
add a new userform, format() and chr() works. So, I am guessing that the
Microsoft guy took the easy route and agreed with me about needing the
"Microsoft Windows CommonControls-26.0 (SP4)".

Any suggestion on how to make this to work? I am going to try and copy all
the slides to a new PPT and import the userform on the laptop.

Wish me luck!!!
 
recap: I send a client a PPT with a userform. It keep crashing on him. But
it worked on my developing computer. I tested it on my laptop and had the
same problem as the client. I isolated the problem to format() and chr() not
being recognized.

Again, both Format and Chr are part of VBA and have nothing to do with any control
that you might be using.

However, it sounds like you have a control on the form that is NOT part of the normal
set included with Office VBA. I'm guessing it might be a database control of some
time but w/o more information, I can't say.

What control did MS give you a link to download? If you're using it in your project,
then you'll have to be certain that it's installed on other PCs where you want your
project to run.



By taking these out of my code the Userform worked without
 
Back
Top