Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

HOW WOULD YOU CHANGE THE CODE TO REFERENCE

link99sbc (TechnicalUser) (OP)
15 May 09 15:47
HOW WOULD YOU CHANGE THE CODE TO REFERENCE
A FILE THAT'S ALREADY OPEN INSTEAD OF OPENING
A NEW INSTANCE EVERYTIME YOU RUN THE MACRO.

SAMPLE
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
    Dim Sessions As Object
    Dim System As Object
    Set System = CreateObject("EXTRA.System")    ' Gets the system object
    If (System is Nothing) Then
        Msgbox "Could not create the EXTRA System object.  Stopping macro playback."
        STOP
    End If
    Set Sessions = System.Sessions

    If (Sessions is Nothing) Then
        Msgbox "Could not create the Sessions collection object.  Stopping macro playback."
        STOP
    End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
    g_HostSettleTime = 1000        ' milliseconds

    OldSystemTimeout& = System.TimeoutValue
    If (g_HostSettleTime > OldSystemTimeout) Then
        System.TimeoutValue = g_HostSettleTime
    End If

' Get the necessary Session Object
    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    If (Sess0 is Nothing) Then
        Msgbox "Could not create the Session object.  Stopping macro playback."
        STOP
    End If
    If Not Sess0.Visible Then Sess0.Visible = TRUE
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    
' This section of code contains the recorded events

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

        
    System.TimeoutValue = OldSystemTimeout
End Sub
 
SkipVought (Programmer)
15 May 09 15:58



Hi,

Please do not SHOUT.  Uppercase is the equivalent.

Are you referring to the Excel workbook when you/re referring to a file that is already open?

Check VBA Help examples in the Excel VB Editor for the GetObject method.

Skip,
glassesDon't let the Diatribe...
talk you to death!tongue

glassesJust traded in my old subtlety...
for a NUANCE!tongue

vzachin (TechnicalUser)
15 May 09 16:23
link99: AttachMate solutions Linkssbc

this was answered on a previous post:

http://www.tek-tips.com/viewthread.cfm?qid=1541923&page=1

i dont open the file because it's already opened
 
link99sbc (TechnicalUser) (OP)
15 May 09 17:19
Ok I figured it out from the other post.
Now how do I make it stop at each cell.
this code just keeps scrolling without stopping
until it reaches a blank cell.

        Dim obj as object
        Dim objWorkbook as object
        Set obj=CreateObject("Excel.Application")

        'Dim Sessions As Object
        'Dim System As Object
        Set System = CreateObject("EXTRA.System")
        Dim Sess As Object
        Set Sess = System.ActiveSession

        Set obj = Getobject("C:\CODE1.xls")       'where xxxx is the location/name of the file on the C Drive
        set objWorkbook=obj.Worksheets("Sheet1")
                
        For i = 2 To obj.ActiveSheet.Rows.Count  'assumption data begins with row 2
        MyName = objWorkBook.Range("A" & i)      'assumption data begins in column A
    
        If Trim(MyName) = "" Then exit sub

        sess.screen.putstring MyName,4,18        'places the data from Excel in Extra
        'do stuff in extra...
        
        next i                                    'i is the next row
        

End Sub
 
vzachin (TechnicalUser)
15 May 09 21:13

Quote:

Now how do I make it stop at each cell.
this code just keeps scrolling without stopping
until it reaches a blank cell.

it is stopping at each cell. and then

CODE

sess.screen.putstring MyName,4,18
what is happening here over on this line?

i'm not sure what you mean or what you're asking for.
please post your question in another thread along with the code, and what is happening when you step through the code...


 

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!

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