bpatt, If you are interfering with the code in the VBA project in one thread, you cannot call the procedure in the same thread. This is because the code has to be recompiled after a design change. And recompilation will take place only after the main routine is finished.
Try this way:
Sub Button_Click(button_number)
'if you click this button, do something
CheckMacroVersion 'this will check version and import .bas file procedures into a module if not there or older (will delete older version before import if need be)
'Procedure call on a new thread
Application.OnTime Now, "'BtnClick " & button_number & "'"
End Sub
'This code must be in standard module:
Sub BtnClick(button_number)
Select Case button_number
Case 1: 'Load Data'
On Error Resume Next
Application.Run ("Populate_Data_Sheet") 'this procedure code is in the .bas file
On Error GoTo 0
Case 2: 'Publish PDF
On Error Resume Next
Application.Run ("Publish_PDF") 'this procedure code is in the .bas file
On Error GoTo 0
Case Else:
MsgBox ("something went wrong")
End Select
End Sub
Another problem you may encounter.
Programming interference in a VBA project is possible only when the "Trust programmatic access to the project" option is selected, which is turned off by default. If you have no control over the other computers, it will have a problem. And I will mention another one - a secured VBA project.
Artik
Bookmarks