Results 1 to 5 of 5
  1. #1
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    619
    Thanks
    166
    Thanked 75 Times in 66 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 06:32. Reason: deleted <BR> tags which forum entered in post
    Lugh.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

  2. #2
    5 Star Lounger Lugh's Avatar
    Join Date
    Jun 2010
    Location
    Indy
    Posts
    619
    Thanks
    166
    Thanked 75 Times in 66 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.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

  3. #3
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    371
    Thanked 1,457 Times in 1,326 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,054
    Thanks
    2
    Thanked 417 Times in 346 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
    619
    Thanks
    166
    Thanked 75 Times in 66 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.
    ~
    Windows 10 Pro x64 1607; Office 2016 (365 Home) x32; Win Defender, MBAM Pro

    ASRock H97 Anniversary; Xeon E3-1231V3 (like i7)
    Gigabyte GeForce GTX 970; 12GB Crucial DDR3 1600
    Logitech MX Master mouse; Roccat Isku kb

Posting Permissions

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