PDA

View Full Version : Converting Macro To VBA



orbian
06-03-2009, 03:50 AM
I am currently trying to convert Macro's to VBA code using the following:

DoCmd.RunCommand acCmdConvertMacrosToVisualBasic

This works fine, but I am then presented with a message box asking if I wish to do the following:-

'Add error handling to generated functions'
'Include macro comments'

So my question is, how can I disable this box? Im actually using Access to create a tool that will import Macro's from an external database and then convert the imported Macro's into VBA code. I am not interested in adding error handling or include the Macro comments. This tool could be used by a number of people and as Error Handling and Comments are not relevant to the tool functionality, I do not want the user to be presented with these options.

Thanks - Orbian

Oorang
06-03-2009, 08:10 AM
AFAIK, Access does not expose a way to do what you want to do. YOu can kludge something together with sendkeys... But I wouldn't recommend it:)

Sub Test0()
Access.VBE.MainWindow.Visible = False
DoCmd.SelectObject acMacro, "Suppliers", True
SendKeys " %FA{Tab}M{Tab} EIC", True
End Sub

orbian
06-08-2009, 04:02 AM
Hi Aaron

Thank you for your reply. I was afraid that that would be the case and I wouldnt be able to get around this problem.

As for the sendkeys solution. I had previously tried something with the sendkeys but this solution didnt work either. The popup boxes are presented when DoCmd.RunCommand acCmdConvertMacrosToVisualBasic is initiated. Therefore, the code is stuck at this point until the popup box 'OK' or 'CANCEL' buttons have been clicked. Then and only then will the code move on to the next line of code which would then be the sendkey events. At that point the popup boxes are no longer present.

Thanks very much for taking the time to reply to my post

Ian

Oorang
06-08-2009, 06:09 AM
That's why you send them all in one shot:)