Greg
Tue Sep 11 19:12:34 CDT 2007
Elaine,
Sorry for confusing you. I took for granted that you would copy the code
into your VB Editor and run it to see what happened ;-)
"Test" is the macro that I am calling from ScratchMacro. I simply showed
you four different was that I could call it.
1. Test
2. Call Test
3. Application.Run MacroName:="Test"
4. Application.OnTime When:=Now + TimeValue("00:0:02"), Name:="Test"
I set oRng to the selection range just to show you that has nothing to do
with calling a macro.
Copy the code I sent you into your editor and select the Run method. Then
press F1. The help file and examples may clear things up.
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Elaine J. wrote:
> Greg, for some reason, this has just confused me. I'm sure it
> relates to what I am trying to do, but I can't see it just yet.
>
> I have a range called noticeplus, A macro named PrintNOH and I want
> to call another macro called printhrformsRep. How do I translate
> what you have to that? i.e. is what you are calling test where I
> would put the printhrformsrep macro? Do I need to declare any
> additional variables? For instance the word TEST on a line by itself
> doesn't make sense to me. (But then, I'm pretty much a beginner in
> this, so that is probably why.)
>
> Thanks for your help
>
>
>
> "Greg Maxey" wrote:
>
>> Sub ScratchMacro()
>> Dim oRng As Word.Range
>> Set oRng = Selection.Range
>> Test
>> Call Test
>> Application.Run MacroName:="Test"
>> Application.OnTime When:=Now + TimeValue("00:0:02"), Name:="Test"
>> 'runs in 2 seconds
>> End Sub
>> Sub Test()
>> MsgBox "Eureka"
>> End Sub
>>
>>
>> --
>> Greg Maxey/Word MVP
>> See:
>>
http://gregmaxey.mvps.org/word_tips.htm
>> For some helpful tips using Word.
>>
>>
>> Elaine J. wrote:
>>> I have a VBA macro that I am using and I want to call another macro.
>>> I have been tried the two versions of calling a macro below.
>>>
>>> Application.Run MacroName:="[PrintHRFormsRep]"
>>> Application.Run "'Shreveport.doc'!NOH.PrintHRFormsRep"
>>>
>>> But I keep getting an error message that says:
>>>
>>> Unable to run the specified macro.
>>>
>>> The document that I am working in has a range set called noticeplus.
>>> Then I want to call a macro that will open another document, print
>>> it, close it and revert back to the previous active document. Both
>>> macros work independently, but I want to be able to use them
>>> together.
>>>
>>> It occurred to me on the way home tonight that maybe it had
>>> something to do with the range being set. Is there another way to
>>> call a macro when a range is set?
>>>
>>> Both macros are in the same template and module.
>>>
>>> Thanks for any help.