Solved

Access 2, Word 97 macro

Posted on 1998-01-22
5
342 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

726 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