Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Excel Spreadsheet Using Attachmate

Status
Not open for further replies.

gcrane

Programmer
Aug 4, 2014
12
0
0
US
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
 
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
 
because AppActivate is the third line in the code I sent."

No, you CALL AppActivate function here, but where is the function itself?
 
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
 
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 %?
 
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
 
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.
 
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
 
Try

Obj.Visible = TRUE

Also, does the Task Manager indicate that Excel is not in memory?
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top