1

I have this really old macro from 1996 (yes!) that I think is somewhat Visual Basic (not sure tho) that I cannot get to work in VBA. The most of the code is running fine, but I am troubled by the UserForm as it is called Dialog in this code.
I think I need to create a userform instead as VB does not operate with that. But I am not sure how to tackle it. Should I just create a new userform and place the objects according to the coordinates and then it will work or what is best practice?

     Begin Dialog UserDialog x,y,291,171,"Batch Printing",.DialogFunction
            OKButton 204, 152, 40, 14
            CancelButton 248, 152, 40, 14
            Text 8, 4, 20, 8, "Path:", .Text1
            TextBox 8, 16, 96, 12, .dPath
            Text 8, 56, 32, 8, "Files:", .Text2
            ListBox 8, 68, 96, 96, sFilesList$, .dFiles
            PushButton 36, 36, 40, 14, "&Refresh", .dRefresh
            GroupBox 112, 8, 176, 92, "Select a printer", .SelectPrinter
            OptionGroup .PrinterSelection
                    OptionButton 120, 24, 92, 8, "&Default Printer", .DefPrint
                    OptionButton 120, 56, 84, 8, "&Specific Printer", .SpecPrint
            Text 128, 36, 148, 8, sDefaultPrinter, .Text3
            DropListBox 120, 68, 160, 52, sPrinterList, .SpecificPrinter
    End Dialog
Niclas
  • 1,069
  • 4
  • 18
  • 33
  • 1
    IMO the only reliably safe way to "convert" that `UserDialog` is to add a new `UserForm` to your VBA project, and [re-]create it from scratch. – Mathieu Guindon Dec 21 '16 at 15:49
  • @Mat'sMug thanks. I was also think this, but I have a hard time finding information about the `UserDialog` and what these parametres means. – Niclas Dec 21 '16 at 15:52
  • 1
    You're probably better off re-designing it off a screenshot of the original one. The 4 first parameters look like coordinates, and then there's a caption when relevant to the control, and the other parameter seems to assign a *dialog function*, whatever that does. Could possibly be mapping to `Property Get` and `Property Let` members in the dialog's code-behind. – Mathieu Guindon Dec 21 '16 at 15:57
  • 1
    Is that WordBasic? – Comintern Dec 21 '16 at 16:02
  • @Comintern from what I have Googled so far, something could suggest it is, but I am unsure. – Niclas Dec 21 '16 at 16:03
  • Looks like there's an automatic VBA conversion if you open an ancient Word document in Word 2007. [This link](https://msdn.microsoft.com/en-us/library/office/ff194689.aspx) might be helpful. – Comintern Dec 21 '16 at 16:12
  • @Comintern unfortunately, I do not have access to a Word 95 template :-( My macro is an exported file. – Niclas Dec 21 '16 at 16:14
  • I have found this https://msdn.microsoft.com/en-us/library/aa211967(v=office.11).aspx I might be useful, I will take a look. – Niclas Dec 21 '16 at 16:18
  • Yes, that looks like WordBasic to me. (I vaguely remember playing around with WordBasic briefly as a child making a simple guess-my-number game in it.) This is so old it may fit better on Retrocomputing.SE (though I'm only half-serious). As others have said, you'll probably just need to figure out what it's doing and reimplement in current VBA. –  Dec 21 '16 at 17:43

1 Answers1

0

WordBASIC is pretty old. There is some ability in some versions of Word to automatically convert WordBASIC to VBA, so you could try that if you can find the right version (probably the older the better, back to Word 97 when VBA was introduced), but I wouldn't really expect a whole lot out of it.

Your best bet is probably to do as you suggest: Create a new form in VBA style, use the code as a baseline of what controls are needed and roughly how the dialog was laid out, and hook up the logic to the rest of the code as needed.

"Best practice" as with any porting project is to ensure you know the real business requirements as best as you can, and use the existing code as a guideline (and to help understand the real business requirements better), but really implement modern code "the right way" to accomplish your actual business objectives, rather than just trying to port over line by line.