+ Reply to Thread
Results 1 to 3 of 3

VBA to VBS converter - possible?

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    VBA to VBS converter - possible?

    Call me crazy but would it be impossible to write a VBA function that converts a VBA module into VBScript?

    To make it much easier, assume that any module I input is completely 'stand-alone' (i.e. it won't contain references to any global variables/constants nor will it reference any procedures outside of the module)

    Also the converter function doesn't have to output a VBS file, I'd be satisfied with it returning a string (i.e. the string contains the VBA code in VBS format)


    Thinking out loud - for starters, we'd need to deal with:
    1. VBS would have to create an Object to reference the Excel application.Then use this reference to refer to any Excel workbooks, built-in functions etc.
    2. VBA can have named arguments. VBS does not.
    3. Create constants in VBS for any Application Named Constants in the VBA code (e.g. xlDown)
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA to VBS converter - possible?

    I don't know if VBA really supports any kind of reflection so my inclination is that this would be much harder than you think it is. Obvious things that spring to mind are resolving references, so instantiating objects where the New keyword has been used rather than createobject, resolving constants, working out which functions are Excel global as opposed to language calls.

    There's a lot to go at, I'm not sure it's all possible, I suspect that you could get 70% of the way there, but the remaining 30% may not be possible. In all it's probably not worth it and considering that you'd still have to check and hand edit the resulting code, probably not worth it - it would be easier and faster to transfer by hand.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: VBA to VBS converter - possible?

    Thanks Kyle

    Pity. I've been playing around with swarm code (aka Multithreaded VBA) by Daniel Ferry so I'd've loved to convert certain VBA modules into dynamically created VBS files...

+ 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. Converter
    By burak in forum Excel General
    Replies: 0
    Last Post: 05-09-2012, 10:56 AM
  2. [SOLVED] converter
    By recipe type data in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 04-04-2006, 08:20 PM
  3. PDF Converter
    By AccessHelp in forum Excel General
    Replies: 4
    Last Post: 01-07-2006, 10:45 AM
  4. Currency Converter
    By AnisaF in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM

Tags for this Thread

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