Solved

Access 2, Word 97 macro

Posted on 1998-01-22
5
312 Views
Last Modified: 2012-08-13
I am using Access 2, Word 97 on Win 95.
In Access, I have a button to load word with a template.
Then, the sendkeys routine to call a word macro.

For some reason, either Access isn't sending the keys (I doubt this one) or Word is just not receiving/opening the keys to get the macro running.  I can manually go to the macros and get the macro running.

Is it possible, to have Word run the macro?
BTW, this worked fine when I had used word 95.
0
Comment
Question by:patricks
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:ramrom
Comment Utility
Sub run_macro
  Dim x As Object
  Set x = CreateObject("word.application.8")
  x.run ("macro1")
End Sub

This will start a copy of Word 97, run the macro named Macro1, and terminate Word. There are variations, such as making x global to keep word open, and using getobject() to see if word is already running.
0
 

Author Comment

by:patricks
Comment Utility
I am opening word with the shell function.  This part works fine.
I would prefer to use sendkeys to send the keys to choose the macro and to get it to run.  Sendkeys worked fine when I was using Word95.

I would prefer to do it this way, because I have better error checking done with the code.
0
 
LVL 5

Accepted Solution

by:
cekman earned 70 total points
Comment Utility
Following is a excerpt from WORD 95 help for AUTO Macros. This way you can have a macro run whenever your template opens.....

By giving a macro a special name, you can run it automatically when you perform an operation such as starting Word or opening a document. Word recognizes the following names as automatic macros, or "auto" macros.

Macro name      When it runs
AutoExec      When you start Word
AutoNew      Each time you create a new document
AutoOpen      Each time you open an existing document
AutoClose      Each time you close a document
AutoExit      When you quit Word
Just like other macros, auto macros can be defined either globally or for a particular template. The only exception is the AutoExec macro, which will not run automatically unless it is stored in the Normal template or a global template stored in the folder specified as the Startup folder.

Tip

You can hold down the SHIFT key to prevent auto macros from running. For example, if you create a new document based on a template that contains an AutoNew macro, you can prevent the AutoNew macro from running by holding down SHIFT when you click the OK button in the New dialog box (File menu) and continuing to hold down SHIFT until the new document is displayed. In a macro that might trigger an auto macro, you can use DisableAutoMacros to prevent auto macros from running.
0
 
LVL 17

Expert Comment

by:ramrom
Comment Utility
Word 97 appears to be immune to sendkeys. I can't get it to even accept text.
0
 

Author Comment

by:patricks
Comment Utility
I have two (2) macros for one template.  The macro that should be running depends on the button that the user presses in Access.

This would not be suitable for users since for one button that they choose, they will need to press the shift key or not to press the shift key.  I believe that this would confuse the users more than anything.

Preferably, I would like  to have sendkeys send the keys and to call the appropriate macro (depending on the  button that is pressed in Access).
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now