PC Review


Reply
Thread Tools Rate Thread

AppActivate problem

 
 
paVBAuser
Guest
Posts: n/a
 
      6th Apr 2008
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
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      6th Apr 2008
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

 
Reply With Quote
 
Kevin
Guest
Posts: n/a
 
      6th Apr 2008
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

 
Reply With Quote
 
Dave D-C
Guest
Posts: n/a
 
      7th Apr 2008
WordID and ExcelID must be Long, not String.

paVBAuser <(E-Mail Removed)> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell and AppActivate problem Doug Sanders Microsoft Access External Data 4 2nd Jun 2007 04:57 AM
Problem with AppActivate. BristolBloos Microsoft Excel Programming 1 14th Oct 2005 08:27 AM
Another AppActivate Problem =?Utf-8?B?TWF0dA==?= Microsoft Access VBA Modules 1 21st Oct 2004 11:35 PM
AppActivate problem when called twice =?Utf-8?B?U3VwZXJKYXM=?= Microsoft Excel Programming 0 3rd Mar 2004 06:41 AM
AppActivate Problem John McEnany Microsoft Access VBA Modules 0 16th Feb 2004 02:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:05 PM.