Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-31-2013, 09:04 AM
kahheng93 kahheng93 is offline How to use this function in microsoft word? Windows 7 32bit How to use this function in microsoft word? Office 2007
Novice
How to use this function in microsoft word?
 
Join Date: Dec 2013
Posts: 5
kahheng93 is on a distinguished road
Default How to use this function in microsoft word?


I am trying to implement the formula from here into microsoft word. It is working in excel but I always get Syntax Error (xxx) in microsoft word though. I tried looking everywhere on the web but still cant figure out how to do this in microsoft word,anyone can lend a hand? Really appreciate it!
Reply With Quote
  #2  
Old 12-31-2013, 03:53 PM
fumei fumei is offline How to use this function in microsoft word? Windows 7 64bit How to use this function in microsoft word? Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Works perfectly for me.

Code:
Sub TryIt()
Selection.TypeText ConvertCurrencyToEnglish("234.56")
End Sub
And I get:

Two Hundred Thirty Four Dollars And Fifty Six Cents

I did have to carefully clean up the copy and paste from that web page. It added a whole bunch of spaces. But the code works in Word. There is no syntax error in the code itself. If you are getting one there is something wrong with the text you are using.
Reply With Quote
  #3  
Old 12-31-2013, 05:11 PM
kahheng93 kahheng93 is offline How to use this function in microsoft word? Windows 7 32bit How to use this function in microsoft word? Office 2007
Novice
How to use this function in microsoft word?
 
Join Date: Dec 2013
Posts: 5
kahheng93 is on a distinguished road
Default

Can i know what is that code you posted for? And i thought spaces doesnt matter in code? Sorry still new at this x.x
Reply With Quote
  #4  
Old 12-31-2013, 05:25 PM
kahheng93 kahheng93 is offline How to use this function in microsoft word? Windows 7 32bit How to use this function in microsoft word? Office 2007
Novice
How to use this function in microsoft word?
 
Join Date: Dec 2013
Posts: 5
kahheng93 is on a distinguished road
Default

I tried added that code of yours to the end of the code from that page, then i tried to run macro,and it works!! but how do I make it convert any numbers i want without keep changing the numbers in module?Thanks!
Reply With Quote
  #5  
Old 12-31-2013, 06:56 PM
kahheng93 kahheng93 is offline How to use this function in microsoft word? Windows 7 32bit How to use this function in microsoft word? Office 2007
Novice
How to use this function in microsoft word?
 
Join Date: Dec 2013
Posts: 5
kahheng93 is on a distinguished road
Default

I put this code in the module :


Then i go to word,create a table, and insert this:


But all i get is this:


Can i know how to make it work? I tried to use your code and yes it works but everytime i want to convert a different number I have to edit the code. Is there anyway simpler? This is intended for my mother for her work, and I doubt she can remember all the steps to go into the code and edit it everytime.
Reply With Quote
  #6  
Old 12-31-2013, 07:31 PM
macropod's Avatar
macropod macropod is offline How to use this function in microsoft word? Windows 7 32bit How to use this function in microsoft word? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

kahheng93: Please don't post multiple screenshots. If you want to post:
• code, post that (using the code tags on the advanced page)
• error messages, post those as text.
For a Word-based macro to convert numbers to text, see: http://gregmaxey.com/word_tip_pages/..._currency.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 12-31-2013, 08:49 PM
kahheng93 kahheng93 is offline How to use this function in microsoft word? Windows 7 32bit How to use this function in microsoft word? Office 2007
Novice
How to use this function in microsoft word?
 
Join Date: Dec 2013
Posts: 5
kahheng93 is on a distinguished road
Default

noted, wont happen again. i tried the link,first method do not allow me to edit the words such as 'dollars' ; second method has compile error syntax error when trying to run ; third method has errors when running the add-ins suchs as : "Could not load an object because it is not available on this machine" or "Compile error in hidden module" or macro cannot be found or has been disabled because of your macro security settings". I tried enabled all macros in trust center and trust access to vba project object model... nothing works so far... x.x
Reply With Quote
  #8  
Old 12-31-2013, 09:20 PM
macropod's Avatar
macropod macropod is offline How to use this function in microsoft word? Windows 7 32bit How to use this function in microsoft word? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by kahheng93 View Post
i tried the link,first method do not allow me to edit the words such as 'dollars'
Microsoft’s ‘DollarText’ field switch doesn’t allow you to specify anything other than dollars. It also doesn't express a value as ‘X dollars and Y cents’ – it returns ‘X and Y/00’. Here’s a field code that takes a more sophisticated approach that allows you to change the currency and use much greater values:
Code:
{QUOTE {ASK Val "What is he amount?"}
{SET AbsVal {=ABS(Val)}}
{IF{=Val}< 0 "Minus "}
{IF{=INT(AbsVal/100000000)}<> 0 "{=INT(AbsVal/100000000) \*Cardtext} hundred "}
{IF{=MOD(INT(AbsVal/1000000),100)} <> 0 "{IF{=INT(AbsVal/100000000)}<> 0 "and "}"}
{IF{=INT(AbsVal/1000000)}<> 0 "{=MOD(INT(AbsVal/1000000),100) \*Cardtext} million, "}
{IF{=INT(AbsVal/100000)}<> 0 "{=MOD(INT(AbsVal/100000),10) \*Cardtext} hundred "}
{IF{=MOD(INT(AbsVal1000),100)} <> 0 "{IF{=INT(AbsVal/100000)}<> 0 "and "}"}
{IF{=INT(AbsVal/1000)}<> 0 "{=MOD(INT(AbsVal/1000),100) \*Cardtext} thousand, "}
{IF{=MOD(INT(AbsVal/100),10)}<> 0 "{=MOD(INT(AbsVal/100),10) \*Cardtext} hundred "}
{IF{=MOD(INT(AbsVal),100)}<> 0 "{IF{=INT(AbsVal/100)}<> 0 "and "}{=MOD(INT(AbsVal),100) \*Cardtext} "}
{=INT(AbsVal) \# \dollar;;}{IF{=INT(AbsVal)}> 1 "s"}
{IF{=MOD(AbsVal,1)}<> 0 "{IF{=INT(AbsVal)}<> 0 " and "}{=MOD(AbsVal,1)*100 \*Cardtext} cent{IF{=MOD(AbsVal,1)}> 0.01 s}"} \* FirstCap}
With this field you can go all the way to 999,999,999.99 (technically you could go two orders of magnitude higher). You can omit/edit the:{=INT(Val) \# \dollar;;}{IF{=INT(Val)}> 1 "s"} and {IF{=MOD(Val,1)}> 0.01 cents cent}"}portions if you want no/different currency. You could likewise omit the various tests for inserting 'and ', if you prefer.

Note: The field brace pairs (ie '{ }') for the above example are created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message.

You could also use a macro to convert the above to a working field. For that, see: http://www.gmayor.com/export_field.htm#TextToField
Quote:
second method has compile error syntax error when trying to run
That solution is designed for working with formfields only. Does your document contain the required formfields - with the required names?
Quote:
third method has errors when running the add-ins suchs as : "Could not load an object because it is not available on this machine" or "Compile error in hidden module" or macro cannot be found or has been disabled because of your macro security settings"
Did you install the correct version, as per the instructions given on that site?
Quote:
I tried enabled all macros in trust center and trust access to vba project object model... nothing works so far...
None of that should be necessary; indeed it opens your PC to macro virus attacks.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a graph for Future Value function (FV function) bmoody Excel 2 11-06-2013 10:52 AM
[HELP]Word: sub or function not defined royankidding Word VBA 0 08-29-2013 12:11 AM
OnClick function in Word Lakshit Word 0 09-27-2011 12:11 AM
Is there a function on MS Word showing the lastest changes made on a word file? _____ Word 2 10-30-2010 05:33 AM
Inserting citations using the reference function in Microsoft Word 2007? aeyara Word 0 09-28-2009 05:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:00 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft