Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default AppActivate problem

I'm trying to get the following code to launch Microsoft Word using the
AppActivate method and then return to the orginal workbook. I run the code
by calling Sub Primary which activates UserForm1 which then calls Sub
Secondary.

Sub Primary()
UserForm1.Show 'to display program running message
End Sub

Private Sub UserForm_Activate()
Secondary
Unload Me
End Sub

Sub Secondary()
Dim WordID As String, ExcelID As String
WordID = Shell("C:\Program Files\Microsoft
Office\Office\WINWORD.EXE", 1)
ExcelID = Shell("C:\Program Files\Microsoft
Office\Office\EXCEL.EXE", 1)
On Error GoTo WordError
AppActivate WordID
MsgBox "Word has been activated."
GoTo ResumeExcel
WordError:
MsgBox "Word error"
Exit Sub
ResumeExcel:
On Error GoTo ExcelError
AppActivate ExcelID
MsgBox "Excel has been reactivated."
GoTo EndSub
ExcelError:
MsgBox "Excel error"
Exit Sub
EndSub:
MsgBox "Resume Excel"
End Sub

The program yields an open Word Doc, focus set to a new instance of Excel
(and a new workbook) and a blinking Excel icon in the taskbar (reflecting the
original instance of Excel). Focus is returned to the original workbook when
I click on its icon (in the taskbar). The message "Word error" is displayed
when focus is returned to the original workbook.

Any help will be greately appreciated


Thanks much.
--
Kevin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default AppActivate problem

Here is where winword.exe is located on my PC

C:\Program Files\Microsoft Office\OFFICE11

do a search for windword.exe and check its location

"paVBAuser" wrote:

I'm trying to get the following code to launch Microsoft Word using the
AppActivate method and then return to the orginal workbook. I run the code
by calling Sub Primary which activates UserForm1 which then calls Sub
Secondary.

Sub Primary()
UserForm1.Show 'to display program running message
End Sub

Private Sub UserForm_Activate()
Secondary
Unload Me
End Sub

Sub Secondary()
Dim WordID As String, ExcelID As String
WordID = Shell("C:\Program Files\Microsoft
Office\Office\WINWORD.EXE", 1)
ExcelID = Shell("C:\Program Files\Microsoft
Office\Office\EXCEL.EXE", 1)
On Error GoTo WordError
AppActivate WordID
MsgBox "Word has been activated."
GoTo ResumeExcel
WordError:
MsgBox "Word error"
Exit Sub
ResumeExcel:
On Error GoTo ExcelError
AppActivate ExcelID
MsgBox "Excel has been reactivated."
GoTo EndSub
ExcelError:
MsgBox "Excel error"
Exit Sub
EndSub:
MsgBox "Resume Excel"
End Sub

The program yields an open Word Doc, focus set to a new instance of Excel
(and a new workbook) and a blinking Excel icon in the taskbar (reflecting the
original instance of Excel). Focus is returned to the original workbook when
I click on its icon (in the taskbar). The message "Word error" is displayed
when focus is returned to the original workbook.

Any help will be greately appreciated


Thanks much.
--
Kevin

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default AppActivate problem

Thanks for the quick reply Joel and for reminding me to verify the path to
WINWORD. I'm using Office 2000 and the path reflected in my code is correct.

"Joel" wrote:

Here is where winword.exe is located on my PC

C:\Program Files\Microsoft Office\OFFICE11

do a search for windword.exe and check its location

"paVBAuser" wrote:

I'm trying to get the following code to launch Microsoft Word using the
AppActivate method and then return to the orginal workbook. I run the code
by calling Sub Primary which activates UserForm1 which then calls Sub
Secondary.

Sub Primary()
UserForm1.Show 'to display program running message
End Sub

Private Sub UserForm_Activate()
Secondary
Unload Me
End Sub

Sub Secondary()
Dim WordID As String, ExcelID As String
WordID = Shell("C:\Program Files\Microsoft
Office\Office\WINWORD.EXE", 1)
ExcelID = Shell("C:\Program Files\Microsoft
Office\Office\EXCEL.EXE", 1)
On Error GoTo WordError
AppActivate WordID
MsgBox "Word has been activated."
GoTo ResumeExcel
WordError:
MsgBox "Word error"
Exit Sub
ResumeExcel:
On Error GoTo ExcelError
AppActivate ExcelID
MsgBox "Excel has been reactivated."
GoTo EndSub
ExcelError:
MsgBox "Excel error"
Exit Sub
EndSub:
MsgBox "Resume Excel"
End Sub

The program yields an open Word Doc, focus set to a new instance of Excel
(and a new workbook) and a blinking Excel icon in the taskbar (reflecting the
original instance of Excel). Focus is returned to the original workbook when
I click on its icon (in the taskbar). The message "Word error" is displayed
when focus is returned to the original workbook.

Any help will be greately appreciated


Thanks much.
--
Kevin

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default AppActivate problem

WordID and ExcelID must be Long, not String.

paVBAuser wrote:
..
Dim WordID As String, ExcelID As String
WordID = Shell("C:\Program Files\Microsoft
Office\Office\WINWORD.EXE", 1)
ExcelID = Shell("C:\Program Files\Microsoft
Office\Office\EXCEL.EXE", 1)
..



----== Posted via Pronews.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.pronews.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= - Total Privacy via Encryption =---
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with AppActivate ("Microsoft Excel") Raj[_2_] Excel Programming 0 February 29th 08 10:42 AM
AppActivate BristolBloos Excel Programming 1 October 14th 05 01:01 PM
Problem with AppActivate. BristolBloos Excel Programming 1 October 14th 05 08:27 AM
appactivate Philip Kopf Excel Programming 3 August 23rd 04 05:06 AM
AppActivate problem when called twice SuperJas Excel Programming 0 March 3rd 04 06:41 AM


All times are GMT +1. The time now is 01:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"