×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Opening Excel Spreadsheet Using Attachmate

Opening Excel Spreadsheet Using Attachmate

Opening Excel Spreadsheet Using Attachmate

(OP)
The code below used to work when my company was on Windows XP, MS Office 2003, and an earlier version of Attachmate. Now we are using Windows 7, MS Office 2010, and Attachmate 9.2. The problem I am having is with the last line sending keys to open the file I want. The error message displays: "Illegal function call . . " Any and all assitance is greatly appreciated!

Dim Hwnd as Integer
hWndExcel = Shell("C:\Program Files (x86)\Microsoft Office\Office14\Excel.exe", 1)
AppActivate "Microsoft Excel - Book1"
SendKeys "%FOH:\System Security\SSS\Quarterly Reports\MACROS\QTRLYDDA.xlsm",1

Thank you!
gcrane

RE: Opening Excel Spreadsheet Using Attachmate

Where is your AppActivate function?

RE: Opening Excel Spreadsheet Using Attachmate

(OP)
Thank you for your quick response!
I'm a little confused at your question because AppActivate is the third line in the code I sent. The macro editor gets passed this line just fine, but throws the error message at the last line. I did look at the original macro that someone else wrote and could not find any other referece to AppActivate nor any functions.

Please advise!
gcrane

RE: Opening Excel Spreadsheet Using Attachmate

"because AppActivate is the third line in the code I sent."

No, you CALL AppActivate function here, but where is the function itself?

RE: Opening Excel Spreadsheet Using Attachmate

(OP)
Skip
Again, I am confused by your question as it looks like an internal command for EXTRA! Basic. I looked it up in the help files and copied it below.

Environment Control
EXTRA! Basic includes the ability to call another software application
(AppActivate), and send the application keystrokes (SendKeys).

AppActivate (statement) — Activates an application window
AppActivate string-expression
Activates an application window.
stringexpression - The name (from the title bar) of the application you want to activate. Both the title bar and string-expression must be spelled identically. However, the comparison is not case sensitive.
Comments
AppActivate changes the focus to the specified window but will not automatically maximize an application if it is currently minimized.
AppActivate can be used in combination with the SendKeys statement to send keystrokes to another application.
Note: If there is more than one application window named stringexpression, EXTRA! Basic chooses randomly from the pool of matching
windows.
AppActivate (statement) Example
This example opens the Windows bitmap file ARCADE.BMP in
Paintbrush. (Paintbrush must already be open before running this
example. It must also not be minimized.)

Sub main
MsgBox "Opening C:\WINDOWS\ARCADE.BMP in Paintbrush."
AppActivate "Paintbrush - (Untitled)"
SendKeys "%FOC:\WINDOWS\ARCADE.BMP{Enter}",1
MsgBox "File opened."
End Sub

RE: Opening Excel Spreadsheet Using Attachmate

Great. I never used that function and I don't have the Extra HELP file on my iPad.

What about ther SebdKeys string? Why the leading %?

RE: Opening Excel Spreadsheet Using Attachmate

(OP)
Sendkeys is one of the most widely used commands in an Attachmate macro. It sends keystrokes. The % is for the alt key.

That is the problem I am having is that the communication between my macro and Excel is failing. That is why I specified the versions of the programs I am currently using.

I want Excel to use the menu to open a specific spreadsheet file. It no longer accepts "%FO" as a legitimate function.

Plaease advise!
- gcrane

RE: Opening Excel Spreadsheet Using Attachmate

I'd use the CreateObject function to create the Excel application object.

Then using that object, use the Workbooks.Open method to open the specific workbook.

RE: Opening Excel Spreadsheet Using Attachmate

(OP)
You mean like the below:

Dim obj as object
Dim objWorkbook as object
Set obj = CreateObject("Excel.Application")
obj.Workbooks.Open FileName:="H:\System Security\SSS\Quarterly Reports\MACROS\QTRLYDDA.xlsm"

I don't know why, but this does NOT work. Also, I was hoping to find out how to use 'Sendkeys' because I wanted to use the menu to run an Excel macro after the spreadsheet is opened.

Any further thoughts?
- gcrane

RE: Opening Excel Spreadsheet Using Attachmate

Try

Obj.Visible = TRUE

Also, does the Task Manager indicate that Excel is not in memory?

RE: Opening Excel Spreadsheet Using Attachmate

gcrane:
skip is correct obj.visible = true
this is an example of how i open the excel sheet

CODE

file = "C:\test.xlsx"
        Dim obj as object
        Dim objWorkbook as object
        Set obj = CreateObject("Excel.Application")
        obj.visible = True
        obj.workbooks.open file 

there is no need to use SendKeys unless it's used for the attachmate screen.

once the Excel sheet is opened, it's fairly easy to pass data from Excel to Attachmate or Attachmate to Excel.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close