![]() |
Call sub from Personal.xls
HI,
I have a 4 workbooks which my users might want to access at the same time. I have a timer module that is used over all four books and runs from personal.xls. I would like to call a sub kept in the active workbook from within the timer module of personal.xls, Can anyone shed some light how I would achieve this. Many thanks Don |
Call sub from Personal.xls
Application.Run("workbook.xls!macro",arg1,arg2,etc )
|
Call sub from Personal.xls
On Jun 18, 2:25*pm, Smallweed
wrote: Application.Run("workbook.xls!macro",arg1,arg2,etc ) Thanks for reply but as mentioned in op this could be one of four workbooks (in fact more) so I would not know which workbook.xls to specify. Can I use wildcards? Don |
Call sub from Personal.xls
On Jun 18, 3:09*pm, don wrote:
On Jun 18, 2:25*pm, Smallweed wrote: Application.Run("workbook.xls!macro",arg1,arg2,etc ) Thanks for reply but as mentioned in op this could be one of four workbooks (in fact more) so I would not know which workbook.xls to specify. *Can I use wildcards? Don Any other thoughts please? Don |
Call sub from Personal.xls
Maybe...(untested)
Option Explicit Sub testme() Dim ok As Boolean Dim wkbk As Workbook ok = False For Each wkbk In Application.Workbooks On Error Resume Next Application.Run "'" & wkbk.Name & "'!macronamehere", "parm1" If Err.Number < 0 Then Err.Clear Else ok = True Exit For End If On Error GoTo 0 Next wkbk If ok = False Then MsgBox "Failed!" Else MsgBox "may it worked???" End If End Sub don wrote: On Jun 18, 3:09 pm, don wrote: On Jun 18, 2:25 pm, Smallweed wrote: Application.Run("workbook.xls!macro",arg1,arg2,etc ) Thanks for reply but as mentioned in op this could be one of four workbooks (in fact more) so I would not know which workbook.xls to specify. Can I use wildcards? Don Any other thoughts please? Don -- Dave Peterson |
Call sub from Personal.xls
On Jun 19, 1:14*pm, Dave Peterson wrote:
Maybe...(untested) Option Explicit Sub testme() * * Dim ok As Boolean * * Dim wkbk As Workbook * * ok = False * * For Each wkbk In Application.Workbooks * * * On Error Resume Next * * * Application.Run "'" & wkbk.Name & "'!macronamehere", "parm1" * * * If Err.Number < 0 Then * * * * Err.Clear * * * Else * * * * ok = True * * * * Exit For * * * End If * * * On Error GoTo 0 * * Next wkbk * * If ok = False Then * * * MsgBox "Failed!" * * Else * * * MsgBox "may it worked???" * * End If End Sub don wrote: On Jun 18, 3:09 pm, don wrote: On Jun 18, 2:25 pm, Smallweed wrote: Application.Run("workbook.xls!macro",arg1,arg2,etc ) Thanks for reply but as mentioned in op this could be one of four workbooks (in fact more) so I would not know which workbook.xls to specify. *Can I use wildcards? Don Any other thoughts please? Don -- Dave Peterson- Hide quoted text - - Show quoted text - Thanks for suggestion I'll post back to let you know if it worked. Thanks again |
Call sub from Personal.xls
On 19 Jun, 17:36, don wrote:
On Jun 19, 1:14*pm, Dave Peterson wrote: Maybe...(untested) Option Explicit Sub testme() * * Dim ok As Boolean * * Dim wkbk As Workbook * * ok = False * * For Each wkbk In Application.Workbooks * * * On Error Resume Next * * * Application.Run "'" & wkbk.Name & "'!macronamehere", "parm1" * * * If Err.Number < 0 Then * * * * Err.Clear * * * Else * * * * ok = True * * * * Exit For * * * End If * * * On Error GoTo 0 * * Next wkbk * * If ok = False Then * * * MsgBox "Failed!" * * Else * * * MsgBox "may it worked???" * * End If End Sub don wrote: On Jun 18, 3:09 pm, don wrote: On Jun 18, 2:25 pm, Smallweed wrote: Application.Run("workbook.xls!macro",arg1,arg2,etc ) Thanks for reply but as mentioned in op this could be one of four workbooks (in fact more) so I would not know which workbook.xls to specify. *Can I use wildcards? Don Any other thoughts please? Don -- Dave Peterson- Hide quoted text - - Show quoted text - Thanks for suggestion I'll post back to let you know if it worked. Thanks again- Hide quoted text - - Show quoted text - Yes worked fine thanks Don |
All times are GMT +1. The time now is 11:59 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com