Solved

Access 2, Word 97 macro

Posted on 1998-01-22
5
333 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
ID: 1966478
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
ID: 1966479
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
ID: 1966480
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
ID: 1966481
Word 97 appears to be immune to sendkeys. I can't get it to even accept text.
0
 

Author Comment

by:patricks
ID: 1966482
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

825 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