Solved

Access 2, Word 97 macro

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

895 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

11 Experts available now in Live!

Get 1:1 Help Now