0

vb6 uses vba for "macro" writing. I can find no documentation on how to do this.

This is a legacy VB6 program written sometime before 2004. I have requirements to update a small bit of it, but it requires editing of the user's macro. I cannot figure out how to "get at" the user's code.

I have the VB6 source code. My client purchased VBA from Microsoft. VBA for VB6 was also available from MSDN in September 2004 under the name "Microsoft Visual Basic for Applications 6.0 SDK Version 6.4 Release Handbook". There is one trivial example and poor documentation. The application allows the user to enter VBA code (most of the time a sort of question) like:

`Sex = Male
 If Employee.Age = 16 Then
    Print Employee.Name, Employee.Age
 End if`

Some of the "questions" consist of a couple of hundred lines of code. The VB6 program "somehow" executes the "question" and returns output to the user in a rich textbox.
When I look on the Web for VBA and VB6 (and i have done so with many variations) Google and Bing (among others) simply don't understand any questions about hooking VBA to VB6. There are applications (VISIO) which have included VBA. So somewhere, somebody, must know how to put VBA into an application (it is a COM afterall) or where decent documentation exists to accomplish this. --Charlie

  • https://support.office.com/en-ie/article/show-the-developer-tab-e1192344-5e56-4d45-931b-e5fd9bea2d45 – cyboashu Apr 04 '19 at 20:05
  • 1
    Is this VBA within an Office application like Word, Excel? – StayOnTarget Apr 04 '19 at 20:10
  • Assuming an Excel host, this will be much easier to accomplish if your VB6 project references the Excel type library, and "getting at" the VBA project will be much easier to do if you're referencing the VBIDE Extensibility library. Depending on what the "editing" needs to do, you'll have quite a bit of "fun" dealing with code-as-plain-strings there. If you have a `Workbook` object, you can get to its associated VBProject through its `VBProject` property... and accessing it may require explicitly enabling programmatic access to the VBE, in macro security settings. – Mathieu Guindon Apr 04 '19 at 20:26
  • As for this particular question, it's ...too broad to be answerable in its current form. Please [edit] to clarify. – Mathieu Guindon Apr 04 '19 at 20:26
  • Are you saying you have a compiled VB6 application/executable? If Yes then I'm not sure there's any easy way to make edits, but see for example https://stackoverflow.com/questions/414068/is-there-a-visual-basic-6-decompiler – Tim Williams Apr 04 '19 at 20:35
  • VB6 hosts the VBA language. VB6 itself is a forms package, an application object (plus clipboard and printer). Code is written in VBA. Unlike VBA in Office in VB6 the code is compiled then distributed. In Offiice it is compiled everytime it is run. – Noodles Apr 04 '19 at 21:33
  • I have the VB6 project source code. The client purchased VBA from Microsoft. I have that package (from the client). It was also available from MSDN in September 2004 under the name "Microsoft Visual Basic for Applications 6.0 SDK Version 6.4 Release Handbook" but the documentation is lacking. The application exposes some "things" to VBA and the user writes VBA code. This code is "executed" by the VB6 program and the results displayed to the user in a textbox. There is no Excel or any other Office modules. – Charlie Elliot Apr 07 '19 at 19:58

0 Answers0