Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell And AppActivate:Problems with MENU BAR

Status
Not open for further replies.

larryjr

Technical User
Aug 27, 2001
20
0
0
JP
Hi, I need your help to solve this problem;

Public Sub MyShell()
Dim ReturnValue As Long
Dim myApp As Excel.Application

ReturnValue = Shell("c:\Program Files\Microsoft _
Office\Office\EXCEL.EXE", vbMaximizedFocus)
AppActivate ReturnValue
Set myApp = GetObject(, "Excel.Application")
myApp.ActiveSheet.Cells(1, 1).Value = 2345656
AppActivate "Microsoft Word"
ThisDocuments.Activate
End Sub

Working with the VBA in Word97 to create Excel Workbook
and return to Word again, I used the procedure above.
Problem IS that after I got back Word its MENU BAR got
inactive and could not work until I selected the wondow
again after selecting other application window.

I need the clue to correct this procedure.

LarryJR


 
I had in your code an error with the
"Set myApp = GetObject(, "Excel.Application")"
The Excel isn't run, yet, when the command gets the focus. I don't know, is it your problem, too, or not.

i try what your code does with an another way:
Public Sub MyShell()
Dim xlApp, xlBook, xlExcel As Object
' Dim wrdDoc As Object
' Set wrdDoc = Me.Application.ActiveDocument
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlExcel = xlBook.Worksheets(1)
xlExcel.Cells(1, 2) = 2345658
xlApp.Application.Visible = True
Me.Application.Activate
' wrdDoc.Activate
End Sub
 
Hi ide,
Thank you for replying to my question.
I appreviate your idea using "CreateObject" for
much better preformances after getting back to Word,
and I found that it worked beautifully.

I am still trying to understand how to use "Shell" function
plus "AppActivate" comparing with "CreateObject" method,
wondering how to get control of Excel and back to Word
without MENU freezing.
The problem you pointed at the line ;
"Set myApp = GetObject(, "Excel.Application")"
I once got the same situation,i.e. ERR429 ActiveX component
can not create a object,but procedure can be continued with
VBE debug choice for "continue" after Excel window stops.
It looks like timing problem for ActiveX ?

Including the solution to this ERR429, please let me know
how to control of Excel from Word using "Shell" &
"AppActivate" getting back to Word again safely.

LarryJR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top