How to rewrite VBA code into VBScript code (tools / rules)

I cannot find this information on the site using the search function. And I saw a similar post in C # in Java and VBA in C # in this post

I raise this question because, in my opinion, this is at least partially achievable, if not all, and this would be a useful guide for others to make the transformation. Example example found on the net: here

Can ALL VBA be converted to VBS after some processing (code change)?

If not, what type of VBA program cannot be converted?

If so, is there a vba program or any tools to do this automatically? If not, can you please provide a complete list of conversion rules from VBA to VBS? (I would like to write a VBA program to automatically start this process, if possible)

I only know the following Rules (Please correct me if I am wrong)

  • Delete claim type

VBA: Dim a as string
VBS: Dim a

VBA: Xlup
VBS: -4162

  • You cannot use the redim someArray( A to B) syntax in VBS (VBS always starts at index 0)

VBA: Redim someArray( 1 to 10)
VBS: redim someArray(10)

  • You cannot specify a specific iterator in a for loop in VBS

VBA:

 For i = 1 to 10 'do something next i 

VBS:

 For i = 1 to 10 'do something next 

Always need the full range in VBS (demo only.)

VBA: range("A1") = "Testing"

VBS: ExcelObj.Workbooks(1).Worksheets(1).Range("A1") = "Testing"

  • VBS cannot use VBA collection type (or am I not using the correct CreateObject?)

PS I am aware of this list and this list

Any help would be appreciated, thanks in advance and sorry for the long question.

EDIT: I am working on a script myself, updating when I finish

+6
source share

All Articles