PC Review


Reply
Thread Tools Rate Thread

Call sub from Personal.xls

 
 
don
Guest
Posts: n/a
 
      18th Jun 2008
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
 
Reply With Quote
 
 
 
 
Smallweed
Guest
Posts: n/a
 
      18th Jun 2008
Application.Run("workbook.xls!macro",arg1,arg2,etc)


 
Reply With Quote
 
don
Guest
Posts: n/a
 
      18th Jun 2008
On Jun 18, 2:25*pm, Smallweed <Smallw...@discussions.microsoft.com>
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
 
Reply With Quote
 
don
Guest
Posts: n/a
 
      19th Jun 2008
On Jun 18, 3:09*pm, don <donhar...@gmail.com> wrote:
> On Jun 18, 2:25*pm, Smallweed <Smallw...@discussions.microsoft.com>
> 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
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      19th Jun 2008
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 <donhar...@gmail.com> wrote:
> > On Jun 18, 2:25 pm, Smallweed <Smallw...@discussions.microsoft.com>
> > 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
 
Reply With Quote
 
don
Guest
Posts: n/a
 
      19th Jun 2008
On Jun 19, 1:14*pm, Dave Peterson <peter...@verizonXSPAM.net> 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 <donhar...@gmail.com> wrote:
> > > On Jun 18, 2:25 pm, Smallweed <Smallw...@discussions.microsoft.com>
> > > 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
 
Reply With Quote
 
don
Guest
Posts: n/a
 
      23rd Jun 2008
On 19 Jun, 17:36, don <donhar...@gmail.com> wrote:
> On Jun 19, 1:14*pm, Dave Peterson <peter...@verizonXSPAM.net> 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 <donhar...@gmail.com> wrote:
> > > > On Jun 18, 2:25 pm, Smallweed <Smallw...@discussions.microsoft.com>
> > > > 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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call Macro from PERSONAL.XLS jutlaux Microsoft Excel Programming 4 18th May 2009 06:37 PM
How to Call Functions in the Personal Workbook? SteveM Microsoft Excel Programming 1 18th Dec 2007 03:07 PM
Custom button to call a macro in Personal David Walker Microsoft Excel Programming 1 1st Jul 2006 11:45 PM
Warning 1684 CA2214 : Microsoft.Usage : 'RandomShade..ctor(Int32, Int32, Int32, Int32, Int32)' contains a call chain that results in a call to a virtual method defined by the class. Review the following call stack for unintended consequences: steve bull Microsoft C# .NET 4 7th Jul 2005 05:54 PM
Call a macro in my personal.xls Greg Rivet Microsoft Excel Misc 2 8th Jan 2004 06:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:09 PM.