PDA

View Full Version : Problem switching between Excel and Word



GOGGS75
02-11-2011, 12:32 PM
Hi,

I have managed to set up a number of macros that

1. Switch from Excel to Word
2. Prepare/update word documents
3. Switch back to Excel

The code I use to switch to Word from Excel is as follows:

WORDOPEN = WORDISOPEN (function created manually)
Dim WORDAPP As Word.Application
If WORDOPEN = True Then
Set WORDAPP = GetObject(, "Word.Application")
Else
Set WORDAPP = New Word.Application
End If
WORDAPP.Visible = True
WORDAPP.Activate
WORDAPP.ShowMe

The code I use to switch back to Excel to allow a message to be displayed is as follows:

WORDAPP.Visible=False
Mgbox("Testing")
WORDAPP.Visible=True


A problem I am having is that sometimes (20%) the macro stops processing until the application is switched manually using the mouse at the bottom of the screen.

Has anyone else had this same problem and know of a way to stop it. I have tried Doevents, Appactivate and others unsuccessfully.

Thanks for any help

Goggs75

Tinbendr
02-13-2011, 08:42 AM
The code I use to switch back to Excel to allow a message to be displayed is as follows:

WORDAPP.Visible=False
Mgbox("Testing")
WORDAPP.Visible=True

I think you are going to have to set a Excel application object and Activate it specifcally, instead of depending on System to default back to Excel.