Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Convert Word Macro to Access Procedure?

Discussion in 'Information Technology' started by Tom Brown, Nov 1, 2005.

  1. Tom Brown

    Tom Brown
    Expand Collapse
    Guest

    Is it possible to convert a VBA Macro from MS Word into an Access VBA
    Procedure? Instead of running the procedure (Macro) from MS Word, I would
    like to run it from an Access form with a Command Button. The goal is to
    extract data from a Word document into an Access table.

    For example, the following line gets a compile error

    vCity = Source.FormFields("City").result



    It tells me "The Method or data member is not found." The .FormFields is
    highlighted on the error.



    Any help will be appreciated,



    Tom
     
  2. Loading...

    Similar Threads Forum Date
    Sikhconvert Joins Sikh Philosophy Network! New SPN'ers Aug 28, 2016
    Jehovah's Witnesses Are Out And Converting! Blogs Jul 31, 2016
    Islam Ishna Has Converted To Islam Interfaith Dialogues Apr 1, 2016
    A Christian Missionary tried to convert me. Blogs Oct 22, 2015
    "Convert's Corner" - Ideas for Retitle? Convert's Corner Oct 21, 2015

  3. Tom Wickerath

    Tom Wickerath
    Expand Collapse
    Guest

    Hi Tom,

    Yes, this should be possible. Start by writing early bound code so that you
    will have intellisense to help you. You'll need to set a reference to the
    "Microsoft Word X.XX Object Library", where X.XX represents your version of
    Word. Then you'll need to declare an object variable and set it in the
    procedure, like this:

    Dim objWord As Word.Application
    Set objWord = GetObject(, "Word.Application")

    (You don't need to name it "objWord"--you can name it whatever you want).

    An example of retrieving data from a Word document into an Access table can
    be found here:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnimo01/html/imo1200.asp

    I have a copy of the sample database that goes with this article. If you
    send me a private e-mail message, with a valid reply-to address, I will send
    you this file. My slightly obfuscated e-mail address is shown below. You
    should have 18 characters remaining, after removing the indicated letters and
    spaces. Whatever you do, please do not post your unaltered e-mail address to
    any newsgroup message.


    Tom

    QWaos168@XScom cast. Dnet (<--Remove all capitalized letters and spaces).
    http://www.access.qbuilt.com/html/expert_contributors.html
    __________________________________________

    "Tom Brown" wrote:

    Is it possible to convert a VBA Macro from MS Word into an Access VBA
    Procedure? Instead of running the procedure (Macro) from MS Word, I would
    like to run it from an Access form with a Command Button. The goal is to
    extract data from a Word document into an Access table.

    For example, the following line gets a compile error

    vCity = Source.FormFields("City").result



    It tells me "The Method or data member is not found." The .FormFields is
    highlighted on the error.



    Any help will be appreciated,



    Tom
     

Share This Page