AppActivate Does Not Activate Application

jimjeffco

New Member
Joined
Feb 3, 2004
Messages
8
Building VBA that performs an action using the TextEdit program. This is operating on a Mac with Excel 2004. File path is verified as correct, VBA complies but code generates a run time 5 error on the AppActivate ReturnValue line. Here is the code:

Sub OpenTextEdit()

Dim ReturnValue As Long

ReturnValue = Shell("~Mac 120GB:Applications:TextEdit", 1)
AppActivate ReturnValue

' Other code to run once application is open resides here

End Sub

Even setting the file path to activate Microsoft Word generates the same error.

Thanks in advance.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi Jim,

The code you are using assumes you have notepad already running.

This example illustrates various uses of the AppActivate function to activate an application window. If a Notepad process is not running, the example throws an ArgumentException. The Shell procedure assumes the applications are in the paths specified.

Code:
Dim notepadID As Integer
' Activate a running Notepad process.
AppActivate("Untitled - Notepad") 
' AppActivate can also use the return value of the Shell function.
' Shell runs a new instance of Notepad.
notepadID = Shell("C:\WINNT\NOTEPAD.EXE", AppWinStyle.NormalFocus)
' Activate the new instance of Notepad.  
AppActivate(notepadID)


With yopur code, you may want to try this but don't use a mac so have no idea how it may work.

Code:
Sub OpenTextEdit()

Dim ReturnValue As Long

ReturnValue = Shell("~Mac 120GB:Applications:TextEdit", 1)
call ReturnValue 
AppActivate ReturnValue

' Other code to run once application is open resides here

End Sub
 
Upvote 0
Would this work:

VBA.AppActivate Application.Caption
<!-- / message --><!-- sig -->
 
Upvote 0
Ed and Tom,

I appreciate your input but will need to abandon this project. It appears to be a Excel-Mac issue as even verifying through VBA that the available References are active, a simple statement such as SendKeys generates a run time error as Excel indicates that command does not exist in Mac Excel. I'll wait to run this on a Windows version as that VBA is better documented (and operational from my past VBA experience ) than on the Mac platform.

Jim
 
Upvote 0
Hi Jim,

try this.

Code:
Dim strPath As String
strPath = ("~Mac 120GB:Applications:TextEdit", 1)
Shell strPath & "", vbNormalFocus
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,812
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top