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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Area selection & copy in Attachmate 7.11

Status
Not open for further replies.

MarvellousMicky

IS-IT--Management
Jan 13, 2007
1
GB
Hi

I wonder if anybody could help, it would be much appreciated!!

I am trying to select a specific area of the screen in attachmate & copy it. I'm sure this must be simple to do but I have limited experience with this package.

Would be even better if VB would allow me to select the area in attachmate, copy, then paste into Excel.

Thank you.
Mick
 
Check these FAQ's first. VB(A) is the way to go.

How do I use VB(A) to manipulate attachmate (6.5+)? faq99-4069
How do I get data to Excel? faq99-4068


Calculus
 
This example got me started.

Code:
'==============================================================================
'
'   MACRO NAME:    excel.ebm
'   DATE WRITTEN:  11/21/97, Attachmate Automation Support (ng)
'   DESCRIPTION:   For use with EXTRA! Personal Client 6.x (and derivatives).
'                  Also requires 32-bit Microsoft Excel to be installed.
'
'   NOTES:         This macro illustrates how an Excel spreadsheet can be accessed
'                  and manipulated from within an EXTRA! Basic macro. The macro does
'                  the following steps:
'                  1. Connect to the currently active EXTRA! session.
'                  2. Start Excel.
'                  3. Create an new .xls file (workbook) and save it.
'                  4. Copy the current screen in EXTRA! to the Excel worksheet.
'                  5. Save the worksheet.
'
'                  EXTRA! Basic and Excel VBA are extremely similar. Note that this
'                  macro will run perfectly if the body of it is copied to a Sub in 
'                  an Excel module.
'                  
'                  © Copyright 1989-1997, Attachmate Corporation. All Rights Reserved.
'
'                  This macro is provided as an example only. It is provided as-is,
'                  without warranty or support from Attachmate Corporation.
'                                   
'==============================================================================

Sub Main
   dim sys as Object, sess as Object, xl as Object, wb as Object
   dim iCount as Integer, iRows as long, iCols as long
   dim sFile as String, aline as string
      
   sFile = "C:\Documents and Settings\WinblowME\Desktop\Excel.xls" 
       
   '####################################################################################################
   '##### GET ACCESS TO THE TOP LEVEL E!PC OBJECT...
   '####################################################################################################
   
   set sys = CreateObject("Extra.System")
   
   if sys is nothing then
      msgbox("Could not create Extra.System...is E!PC installed on this machine?")
      exit sub
   end if
   
   '####################################################################################################
   '##### GET ACCESS TO THE CURRENTLY ACTIVE SESSION...
   '####################################################################################################

   set sess = sys.ActiveSession
   
   if sess is nothing then
      msgbox("No session available...stopping macro playback.")
      exit sub
   end if     

   '####################################################################################################
   '##### START EXCEL...IT WILL NOT BE VISIBLE YET, BUT WILL STILL BE IN MEMORY....
   '##### THIS IS THE SAME AS STARTING EXCEL WITH NO CURRENT WORKBOOK
   '####################################################################################################
   
   set xl = CreateObject("Excel.Application")
   
   if xl is nothing then
      msgbox("Could not create Excel.Application...is Excel installed on this machine?")
      exit sub
   end if
       
   '####################################################################################################
   '##### CREATE A NEW WORKBOOK...THIS IS JUST LIKE CHOOSING 'FILE-NEW...'   
   '####################################################################################################

   set wb = xl.Workbooks.Add
   
   if wb is nothing then
      msgbox("Add method of Excel Workbooks object failed.")
      xl.Quit
      exit sub
   end if

   '####################################################################################################
   '##### SAVE THE NEW WORKBOOK JUST CREATED...  
   '##### AN ERROR WILL OCCUR IF THIS FILE CURRENTLY EXISTS AND THE USER CHOOSES
   '##### NOT TO REPLACE THE EXISTING OR CHOOSES CANCEL...
   '##### AN ERROR WILL ALSO OCCUR IF THE SPECIFIED .XLS IS CURRENTLY OPEN,
   '##### SO CLOSE IT BEFORE RUNNING THIS MACRO....
   '####################################################################################################
   
   On Error GoTo error_exit  
   wb.SaveAs(sFile)
       
   iRows = sess.Screen.Rows
   iCols = sess.Screen.Cols

   '####################################################################################################
   '##### COPY THE CURRENT SCREEN TO THE WORKSHEET...
   '##### IT'S LIKELY TO LOOK BEST IF A NON-PORPORTIONAL FONT IS USED.
   '####################################################################################################

   for iCount = 1 to iRows
      aline = sess.Screen.GetString(iCount, 1, iCols)  
      wb.WorkSheets("sheet1").Cells(iCount, 1).Value = aline
      wb.WorkSheets("sheet1").Cells(iCount, 1).Font.Name = "Courier New"
   next iCount  
       
   'SAVE THE CHANGES TO THE WORKBOOK THEN QUIT EXCEL...
   
   wb.Save
error_exit:        
   xl.Quit
   
   if err then              
      msgbox sFile + " was not replaced."         
   else
      msgbox "Created  " + sFile
   end if
   
   exit sub                                                    
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top