Starting Inputbox focused?

L

Lance Hoffmeyer

I am running scripts from SPSS to manipulate Excel
worksheets. At one point I am running a macro in
Excel that brings up an Inputbox

Since I am running from SPSS the Inputbox is not focused
when it opens and I have to hit ALT-TAB to bring it into
focus. Is there a way to have it automatically open
focused?



Sub CreateExcel()
Set objExcelApp = GetObject(,"Excel.Application")
objExcelApp.Visible = True
objExcelApp.Run "addnewsheetifneeded"
End Sub




Sub AddNewSheetIfNeeded()
'Call function to check for any data in active sheet
If Not GetBottomRow = 0 Then
Application.ScreenUpdating = False
'If necessary, add new sheet before the current sheet.
Worksheets.Add after:=ActiveSheet, Count:=1
On Error Resume Next
'Name the sheet
ActiveSheet.Name = Application.InputBox("Enter Worksheet Name", Type:=2)
On Error GoTo 0
Application.ScreenUpdating = True
End If
End Sub
Private Function GetBottomRow() As Long
On Error GoTo NoRow
'Search the entire sheet for any data ("*" is a wildcard)
GetBottomRow = Cells.Find(what:="*", SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
Exit Function
NoRow:
GetBottomRow = 0
End Function
 
J

Jim Cone

Lance,

See if this does it...
AppActivate "Microsoft Excel"

Regards,
Jim Cone
San Francisco, CA

Lance Hoffmeyer said:
I am running scripts from SPSS to manipulate Excel
worksheets. At one point I am running a macro in
Excel that brings up an Inputbox
Since I am running from SPSS the Inputbox is not focused
when it opens and I have to hit ALT-TAB to bring it into
focus. Is there a way to have it automatically open
focused?
Sub CreateExcel()
Set objExcelApp = GetObject(,"Excel.Application")
objExcelApp.Visible = True
objExcelApp.Run "addnewsheetifneeded"
End Sub

-snip-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top