+ Reply to Thread
Results 1 to 7 of 7

Vba in word

  1. #1
    Registered User
    Join Date
    08-08-2014
    Location
    Kent, England
    MS-Off Ver
    2010
    Posts
    19

    Vba in word

    I have the VBA below in excel that will write numbers in words by using =SpellNumber(A1). I now want to do the same thing in word so ive pasted the same VBA in word but am now a bit confused on how i programme the document to say which bit it should be spelling out. I have tried 'toggle field codes' but not quite sure what to put in there. If anyone can help, it would be much apprieciated. Thanks

    Please Login or Register  to view this content.
    Last edited by webstp01; 12-18-2014 at 04:24 AM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,617

    Re: Vba in word

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Vba in word

    Toggling field codes won't do anything to run a macro. You need an event for that, such as exiting a formfield or content control, or double-clicking on a MACROBUTTON field. The latter would also require you to use an inputbox to solicit the amount to convert.

    In any event, Word provides the same functionality via field coding (e.g. http://answers.microsoft.com/en-us/o...2-3ab302c9514b), so that you don't need to use either your vba functions or any of the above methods. Until you provide more information on exactly how you're trying to supply the amount to be converted, no-one can give specific advice as to the best approach.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    Registered User
    Join Date
    08-08-2014
    Location
    Kent, England
    MS-Off Ver
    2010
    Posts
    19

    Re: Vba in word

    I have tried using the field coding in http://answers.microsoft.com/en-us/o...2-3ab302c9514b but this is only useful if the amount hasnt got a decimal so its not what im looking for.

    Basically i have an excel spreadsheet where a user will enter an amount. Using the VBA coding above i was then able to use the spellnumber formula to covert it into words. Both of these cells will be pulled into a word document.

    Im trying to stay away from doing things in excel and start coding it in the word document itself.

    Ive been told you can use VBA in word documents but dont really understand what i need to do to get it working. I was wondering if anyone can help with an easy step by step instructions as I'm not good at this type of thing. I get most formulas/coding from copy and pasting from google.

  5. #5
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Vba in word

    Quote Originally Posted by webstp01 View Post
    I have tried using the field coding in http://answers.microsoft.com/en-us/o...2-3ab302c9514b but this is only useful if the amount hasnt got a decimal so its not what im looking for.
    That simply isn't true. The field code I posted there most certainly caters for cents - you can even see the reference in the field code if you read it. Depending on what you're doing no macros of any kind are required for this in Word!

  6. #6
    Registered User
    Join Date
    08-08-2014
    Location
    Kent, England
    MS-Off Ver
    2010
    Posts
    19

    Re: Vba in word

    Quote Originally Posted by macropod View Post
    That simply isn't true. The field code I posted there most certainly caters for cents - you can even see the reference in the field code if you read it. Depending on what you're doing no macros of any kind are required for this in Word!
    Well it doesnt seem to want to work for me!

  7. #7
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Vba in word

    In this case, you haven't created the field code properly. What did you do to recreate the field in your own document?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Excel macro- Find replace an itallic font word with a regular word?
    By thisisaboutwork in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2013, 01:48 PM
  2. Copy Many Word Docs to New Word Doc (Each Word Doc Should be on New Page)
    By realniceguy5000 in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 05-05-2013, 03:28 AM
  3. Replies: 2
    Last Post: 08-16-2011, 12:08 PM
  4. Replies: 0
    Last Post: 06-15-2011, 02:22 PM
  5. search for a specific word and copy the word and the preceeding words until a comma
    By DHANANJAY in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-31-2005, 09:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1