Results 1 to 5 of 5
  1. #1
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    732
    Thanks
    200
    Thanked 89 Times in 76 Posts

    Export Template VBA to TXT

    I have this code snippet...
    Code:
    ActiveWorkbook.VBProject.VBComponents("Module1").Export"C:\YourFilePath\YourFileName.txt"
    [Note that it's not clear if there's a space between VBComponents and ("Module1") or not]...but get error message...
    word "run-time error 424" "object required"
    ...which seems to be a common generic error when I search on it. My module, path and filename are correct, and I've tried both variations mentioned in the '[Note...]' above.

    I have established a reference to "Microsoft Visual Basic For Applications Extensibility 5.3".

    It's an old template, built 2003-4 and last updated 2012, which means Word 2003 to 2010 were used on it. I'm using 2013 to open it now.

    Sorry I don't recall where I got the snippet a while ago.

    Thanks for any ideas what I might be doing wrong.
    Last edited by Lugh; 2016-01-12 at 05:32. Reason: deleted <BR> tags which forum entered in post
    Lugh.
    ~
    Dell Alienware Aurora R6 (new 2017)
    Windows 10 Home x64 1703; Office 365 x32
    GeForce GTX 1060; 16GB DDR4 2400
    256G SSD, 1TB HD

  2. #2
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    732
    Thanks
    200
    Thanked 89 Times in 76 Posts
    Well, who knew? Copy/Paste the module contents into my text editor [VBscript template] does exactly what I need. Talk about overthinking...

    I'll leave this 'unsolved' for now in case the answer could be useful to someone else in the future.
    Lugh.
    ~
    Dell Alienware Aurora R6 (new 2017)
    Windows 10 Home x64 1703; Office 365 x32
    GeForce GTX 1060; 16GB DDR4 2400
    256G SSD, 1TB HD

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,780
    Thanks
    403
    Thanked 1,554 Times in 1,407 Posts
    Lugh,

    I tried this in Excel and it worked perfectly.

    However, there is no such thing as ActiveWorkbook in WORD!

    If you change ActiveWorkbook to ActiveDocument (the Word equivalent object) it works just fine.

    And there is NO space in the command, with the exception of between the double quotes for module name or in the file spec!

    HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  4. The Following User Says Thank You to RetiredGeek For This Useful Post:

    Lugh (2016-01-13)

  5. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,159
    Thanks
    2
    Thanked 453 Times in 372 Posts
    Quote Originally Posted by Lugh View Post
    I have established a reference to "Microsoft Visual Basic For Applications Extensibility 5.3".
    In addition to setting a reference to Microsoft Visual Basic For Applications Extensibility, the user running the code must also grant access to VBA object model (see under File|Options|Trust Center>Trust Center Settings).
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  6. The Following User Says Thank You to macropod For This Useful Post:

    Lugh (2016-01-13)

  7. #5
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    732
    Thanks
    200
    Thanked 89 Times in 76 Posts
    Quote Originally Posted by RetiredGeek View Post
    However, there is no such thing as ActiveWorkbook in WORD!
    Oh for heavens sake! Overthinking and blind to boot!

    Thanks RG and macropod
    Lugh.
    ~
    Dell Alienware Aurora R6 (new 2017)
    Windows 10 Home x64 1703; Office 365 x32
    GeForce GTX 1060; 16GB DDR4 2400
    256G SSD, 1TB HD

Posting Permissions

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