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

HOW WOULD YOU CHANGE THE CODE TO REFERENCE

Status
Not open for further replies.

link99sbc

Technical User
Apr 8, 2009
141
US
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
 



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,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
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
 
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...


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top