Solved

Access 2, Word 97 macro

Posted on 1998-01-22
5
345 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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 …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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