Call sub from Personal.xls

D

don

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
 
D

don

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
 
D

don

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
 
D

Dave Peterson

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
 
D

don

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








--

Dave Peterson- Hide quoted text -

- Show quoted text -

Thanks for suggestion I'll post back to let you know if it worked.

Thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top