Let Word run a macro from within Excel? 
Author Message
 Let Word run a macro from within Excel?

First of all, I hope I got the right group here, but given the name, I
guess I can't be too far off topic...

What I need to do is: write a macro in Excel VB, that tells Word to
execute one of its own macros (Office 98 on a Mac, if that's relevant).
I'd thought I could use the SendKeys statement for that: attach a
keyboard shortcut to the Word-macro, and then send that shortcut as a
keypress from Excel to Word by means of SendKeys.  But... for some
obscure reason I can't get SendKeys to work at all.  So it looks as if
that's no option.
I tried zillions of things, but to no avail.  The Shell function works,
as does AppActivate, so I can start Word, and can bring it to the front.
Sending any relevant commands Word's way however seems to be next to
impossible...

Any clues, hints, solutions would be very much appreciated.  Preferably
by email, since I don't usually read this group, although I'll try to
keep an eye on it for the upcoming days.

Thanks for any help in advance.

--

Omega Art -- Graphic Design & Layout

** remove NOSPAM from email address when replying **



Sat, 26 May 2001 03:00:00 GMT  
 Let Word run a macro from within Excel?
Hey Hendrick,

This answer might be a bit late but better late then never...

Better newsgroups for this type of questions include:
    microsoft.public.excel.programming
    microsoft.public.word.programming

Your idea of using sendkeys to execute a word macro might work (nice try),
but it is not the best method.  Sending keystrokes is prone to error (ie if
there is an extra message box or whatever on your screen).

To execute a Word macro from an Excel macro use the following code (in your
Excel macro):

  Dim appWord
  Set appWord = CreateObject("Word.Application")
    ' Run Sub procedure.
    appWord.Run "test"
  Set appWord = Nothing

This will run the macro named "test" in word.

Good luck

Gates

Quote:

> First of all, I hope I got the right group here, but given the name, I
> guess I can't be too far off topic...

> What I need to do is: write a macro in Excel VB, that tells Word to
> execute one of its own macros (Office 98 on a Mac, if that's relevant).
> I'd thought I could use the SendKeys statement for that: attach a
> keyboard shortcut to the Word-macro, and then send that shortcut as a
> keypress from Excel to Word by means of SendKeys.  But... for some
> obscure reason I can't get SendKeys to work at all.  So it looks as if
> that's no option.
> I tried zillions of things, but to no avail.  The Shell function works,
> as does AppActivate, so I can start Word, and can bring it to the front.
> Sending any relevant commands Word's way however seems to be next to
> impossible...

> Any clues, hints, solutions would be very much appreciated.  Preferably
> by email, since I don't usually read this group, although I'll try to
> keep an eye on it for the upcoming days.

> Thanks for any help in advance.

> --

> Omega Art -- Graphic Design & Layout

> ** remove NOSPAM from email address when replying **



Mon, 04 Jun 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Running a word Macro & an excel macro

2. Closing Word docs from within Excel macro

3. Run Excel Macro from within Access module

4. Running a Word VBA sub/macro from Excel

5. Running an Excel Macro from Word

6. Run an Excel and Word macros under VB 5.0

7. Run an Excel and Word macros under VB 5.0

8. Excel / excel macros created within Visual Basic

9. Word 97 - Userform within Word VBA macro and exchange of values

10. Macros in Excel: How do I avoid getting confirmation windows when I run the macro

11. Excel -> Word MailMerge (Excel Macro)

12. Word Macro runs then gets Macro Not Found

 

 
Powered by phpBB® Forum Software