Skip to main content

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba

Hi Patrick, 

the following VBA macro demonstrates how to do this in Excel, I've not tested from Rumba script but I believe it should work also from there.

First off, my data.

       

and here is my macro code:

Sub test1()
Dim XLApp As Object
Dim myXLBook As Object
Dim myXLSheet As Object

Set myXLBook = ThisWorkbook 'XLApp.Workbooks("MyEXCEL.xlsx")
Set myXLSheet = myXLBook.Worksheets("Sheet1") 'MYBook.Worksheets("Feuil1")

FindValue = 1.1

Dim LastCell As Range
With Range("A1:A20")
Set LastCell = .Cells(.Cells.Count)
End With
Set FoundCell = Range("A1:A20").Find(What:=FindValue, after:=LastCell)

If Not FoundCell Is Nothing Then
FirstAddr = FoundCell.Address
Else
MsgBox "Value not found in range"
End If
Do Until FoundCell Is Nothing
If FoundCell.Value = FindValue Then
MsgBox FoundCell.Address & " = " & FindValue
ElseIf InStr(1, FindValue, FindValue) > 0 Then
MsgBox FoundCell.Address & " contains " & FindValue
End If
Set FoundCell = Range("A1:A20").FindNext(after:=FoundCell)
If FoundCell.Address = FirstAddr Then
Exit Do
End If
Loop
End Sub

Note: If you set the FirstValue = 1.1, the macro will find any cell in the range which is = 1.1 or contains 1.1 (e.g. $A$11, $A$12 etc.).
Note: If you set the FirstValue to a string, e.g. "aaa", the macro with find any cell in the range which = "aaa" or contains "aaa" (e.g. $A$3, $A$18 etc.). 

Tom


Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Your code not work in RUMBA but this one yes except that it remains the process of EXCEL.

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim MyBook As Object
Dim XLBook As Object
Dim XLSheet As Object
'Dim XLRange As Object
Dim Range As Object
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "monfic.xlsx" '''', ReadOnly:=True
SysDelay 1
Set MYBook = XLApp.Workbooks("monfic.xlsx")
Set XLSheet1 = MYBook.Worksheets("Sheet1")
Set XLSheet2 = MYBook.Worksheets("Sheet2")

Membre = "aaaaa"
XLSheet2.Activate
Dim FoundCell
set FoundCell = MYBook.ActiveSheet.Range("A1:ZZ100000").Find(What:=Membre, LookAt:=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then
XLSheet1.Activate
set FoundCell = MYBook.ActiveSheet.Range("A1:ZZ100000").Find(What:=Membre, LookAt:=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
If FoundCell Is Nothing Then
NonTrouvé = True
print "nontrouvé : " & NonTrouvé
Else
MsgBox "Nom de la feuille active : " & MYBook.ActiveSheet.Name
print FoundCell.address
print FoundCell.value
End If
Else
MsgBox "The name of the active sheet is " & MYBook.ActiveSheet.Name
print FoundCell.address
print FoundCell.value
End If


'XLSheet1.Application.Quit ' Close the EXCEL sheet
XLApp.Workbooks("monfic.xlsx").Close SaveChanges:=False
'MYBook.Saved = True
'ThisWorkbook.Saved = True
'ActiveWorkbook.Close(savechanges:=False)
FoundCell = Nothing
Set Range = Nothing
Set XLSheet1 = Nothing ' Release all EXCEL Objects
Set XLSheet2 = Nothing
Set XLSheet3 = Nothing
Set XLSheet4 = Nothing
Set XLBook = Nothing

XLApp.Quit

Set XLApp = Nothing

stop

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Your code not work in RUMBA but this one yes except that it remains the process of EXCEL.

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim MyBook As Object
Dim XLBook As Object
Dim XLSheet As Object
'Dim XLRange As Object
Dim Range As Object
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "monfic.xlsx" '''', ReadOnly:=True
SysDelay 1
Set MYBook = XLApp.Workbooks("monfic.xlsx")
Set XLSheet1 = MYBook.Worksheets("Sheet1")
Set XLSheet2 = MYBook.Worksheets("Sheet2")

Membre = "aaaaa"
XLSheet2.Activate
Dim FoundCell
set FoundCell = MYBook.ActiveSheet.Range("A1:ZZ100000").Find(What:=Membre, LookAt:=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then
XLSheet1.Activate
set FoundCell = MYBook.ActiveSheet.Range("A1:ZZ100000").Find(What:=Membre, LookAt:=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
If FoundCell Is Nothing Then
NonTrouvé = True
print "nontrouvé : " & NonTrouvé
Else
MsgBox "Nom de la feuille active : " & MYBook.ActiveSheet.Name
print FoundCell.address
print FoundCell.value
End If
Else
MsgBox "The name of the active sheet is " & MYBook.ActiveSheet.Name
print FoundCell.address
print FoundCell.value
End If


'XLSheet1.Application.Quit ' Close the EXCEL sheet
XLApp.Workbooks("monfic.xlsx").Close SaveChanges:=False
'MYBook.Saved = True
'ThisWorkbook.Saved = True
'ActiveWorkbook.Close(savechanges:=False)
FoundCell = Nothing
Set Range = Nothing
Set XLSheet1 = Nothing ' Release all EXCEL Objects
Set XLSheet2 = Nothing
Set XLSheet3 = Nothing
Set XLSheet4 = Nothing
Set XLBook = Nothing

XLApp.Quit

Set XLApp = Nothing

stop

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Your code not work in RUMBA but this one yes except that it remains the process of EXCEL.

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim MyBook As Object
Dim XLBook As Object
Dim XLSheet As Object
'Dim XLRange As Object
Dim Range As Object
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "monfic.xlsx" '''', ReadOnly:=True
SysDelay 1
Set MYBook = XLApp.Workbooks("monfic.xlsx")
Set XLSheet1 = MYBook.Worksheets("Sheet1")
Set XLSheet2 = MYBook.Worksheets("Sheet2")

Membre = "aaaaa"
XLSheet2.Activate
Dim FoundCell
set FoundCell = MYBook.ActiveSheet.Range("A1:ZZ100000").Find(What:=Membre, LookAt:=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then
XLSheet1.Activate
set FoundCell = MYBook.ActiveSheet.Range("A1:ZZ100000").Find(What:=Membre, LookAt:=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
If FoundCell Is Nothing Then
NonTrouvé = True
print "nontrouvé : " & NonTrouvé
Else
MsgBox "Nom de la feuille active : " & MYBook.ActiveSheet.Name
print FoundCell.address
print FoundCell.value
End If
Else
MsgBox "The name of the active sheet is " & MYBook.ActiveSheet.Name
print FoundCell.address
print FoundCell.value
End If


'XLSheet1.Application.Quit ' Close the EXCEL sheet
XLApp.Workbooks("monfic.xlsx").Close SaveChanges:=False
'MYBook.Saved = True
'ThisWorkbook.Saved = True
'ActiveWorkbook.Close(savechanges:=False)
FoundCell = Nothing
Set Range = Nothing
Set XLSheet1 = Nothing ' Release all EXCEL Objects
Set XLSheet2 = Nothing
Set XLSheet3 = Nothing
Set XLSheet4 = Nothing
Set XLBook = Nothing

XLApp.Quit

Set XLApp = Nothing

stop

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Hi Patrick,

the following Rumba script allows me to open and close Excel and Excel gets removed from the mix.


Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Sub Main
Dim XLApp As Object
Set XLApp = CreateObject("Excel.Application")

XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "Book1.xlsm" '''', ReadOnly:=True
XLApp.Visible = 1

Sleep 1000

XLApp.Workbooks("Book1.xlsm").Close SaveChanges:=False
XLApp.Quit

Set XLApp = Nothing
End Sub

I'm running MS Office Pro Plus 2013, you might have something different?

Maybe you can force Excel to close using the following approach (which also works for me)?

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Const WM_CLOSE = &H10

Sub Main
Dim XLApp As Object
Set XLApp = CreateObject("Excel.Application")

XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "Book1.xlsm" '''', ReadOnly:=True
XLApp.Visible = 1

Sleep 1000

XLApp.Workbooks("Book1.xlsm").Close SaveChanges:=False

Sleep 1000
SendMessage Findwindow("XLMAIN", "Excel"), WM_CLOSE, 0, 0
'XLApp.Quit

Set XLApp = Nothing
End Sub

Tom

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Hi Patrick,

the following Rumba script allows me to open and close Excel and Excel gets removed from the mix.


Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Sub Main
Dim XLApp As Object
Set XLApp = CreateObject("Excel.Application")

XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "Book1.xlsm" '''', ReadOnly:=True
XLApp.Visible = 1

Sleep 1000

XLApp.Workbooks("Book1.xlsm").Close SaveChanges:=False
XLApp.Quit

Set XLApp = Nothing
End Sub

I'm running MS Office Pro Plus 2013, you might have something different?

Maybe you can force Excel to close using the following approach (which also works for me)?

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Const WM_CLOSE = &H10

Sub Main
Dim XLApp As Object
Set XLApp = CreateObject("Excel.Application")

XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "Book1.xlsm" '''', ReadOnly:=True
XLApp.Visible = 1

Sleep 1000

XLApp.Workbooks("Book1.xlsm").Close SaveChanges:=False

Sleep 1000
SendMessage Findwindow("XLMAIN", "Excel"), WM_CLOSE, 0, 0
'XLApp.Quit

Set XLApp = Nothing
End Sub

Tom

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba

Thank Tom, first way work, but my code is more complex

The second don't close EXCEL

My Excel is Office Standard 2010 V 14.0.7015.1000 (32bits)

I don't understand why you have XLApp.Visible = True (Ok for me) AND XLApp.Visible = 1 ?


Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Hi Patrick,

on setting the .Visible property True or 1 should both display the instance of Excel. Why have I both, overkill :-)

Can you check to see if

Findwindow("XLMAIN", "Excel")

returns the Windows Handle for the Excel workspace?

I've tested both methods of closing Excel against MS Office 2013 and also MS Office 2007, and both work for me. Although the Title text in the case of Excel 2007 is "Microsoft Excel" and not just "Excel"

Maybe you might try adding an XLApp.DisplayAlerts = False before attempting to close Excel?

Another thing to try would be to turn off your anti-virus, try your macro and see if it closes Excel. The subsequently re-enable your anti-virus program.

If you wish to verify that the issue is not the Rumba script player, you could run the same code (as in my sample) from Outlook or Word etc.

Note: To execute in VBA, you will need to declare the external subroutines and functions as Private

i.e.
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Bon chance,
Tom

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Hi Patrick,

on setting the .Visible property True or 1 should both display the instance of Excel. Why have I both, overkill :-)

Can you check to see if

Findwindow("XLMAIN", "Excel")

returns the Windows Handle for the Excel workspace?

I've tested both methods of closing Excel against MS Office 2013 and also MS Office 2007, and both work for me. Although the Title text in the case of Excel 2007 is "Microsoft Excel" and not just "Excel"

Maybe you might try adding an XLApp.DisplayAlerts = False before attempting to close Excel?

Another thing to try would be to turn off your anti-virus, try your macro and see if it closes Excel. The subsequently re-enable your anti-virus program.

If you wish to verify that the issue is not the Rumba script player, you could run the same code (as in my sample) from Outlook or Word etc.

Note: To execute in VBA, you will need to declare the external subroutines and functions as Private

i.e.
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Bon chance,
Tom

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Hi Patrick,

on setting the .Visible property True or 1 should both display the instance of Excel. Why have I both, overkill :-)

Can you check to see if

Findwindow("XLMAIN", "Excel")

returns the Windows Handle for the Excel workspace?

I've tested both methods of closing Excel against MS Office 2013 and also MS Office 2007, and both work for me. Although the Title text in the case of Excel 2007 is "Microsoft Excel" and not just "Excel"

Maybe you might try adding an XLApp.DisplayAlerts = False before attempting to close Excel?

Another thing to try would be to turn off your anti-virus, try your macro and see if it closes Excel. The subsequently re-enable your anti-virus program.

If you wish to verify that the issue is not the Rumba script player, you could run the same code (as in my sample) from Outlook or Word etc.

Note: To execute in VBA, you will need to declare the external subroutines and functions as Private

i.e.
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Bon chance,
Tom

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Your fIrst code is OK as is but my problem must come of when I declare
MYBook = XLApp.Workbooks("MonFic.xlsx")

And/Or
Set XLSheet1 = MYBook.Worksheets("Sheet1")
Set XLSheet2 = MYBook.Worksheets("Sheet2")

And/Or
Set FoundCell = MYBook.ActiveSheet.Range("N1:N65000").Find(What:=Membre, LookAt:=2, SearchOrder:=2, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)

But I don't know.

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Your fIrst code is OK as is but my problem must come of when I declare
MYBook = XLApp.Workbooks("MonFic.xlsx")

And/Or
Set XLSheet1 = MYBook.Worksheets("Sheet1")
Set XLSheet2 = MYBook.Worksheets("Sheet2")

And/Or
Set FoundCell = MYBook.ActiveSheet.Range("N1:N65000").Find(What:=Membre, LookAt:=2, SearchOrder:=2, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)

But I don't know.

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
I try


Set XLSheet1 = nothing
Set XLSheet2 = nothing
Set MyBook = nothing

after XLApp.Workbooks("MonFic.xlsx").Close

But nothing

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Hi,
tested the code posted by TomFitz and it works as expected. In the process explorer you should see vsp.exe starting up. (this is the Rumba script player) then the Excel spreadsheet, after the sleep time everthing closes!. No Excel or vsp process open!
I always use:
Set XLApp = Nothing
Set XLBook = Nothing
Set XLSheet = Nothing
... before I exit my function.
I had simlar problems a while a go on my dev system which I solved by a reboot. ;-)

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba

I'm sure my pbm is here :
Set FoundCell = MYBook.ActiveSheet.Range("N1:N65000").Find(What:=Membre, LookAt:=2, SearchOrder:=2, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)

Because if I comment this, the process vanish

But I don't know why

Please help-me !


Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba

I'm sure my pbm is here :
Set FoundCell = MYBook.ActiveSheet.Range("N1:N65000").Find(What:=Membre, LookAt:=2, SearchOrder:=2, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)

Because if I comment this, the process vanish

But I don't know why

Please help-me !


Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba

I'm sure my pbm is here :
Set FoundCell = MYBook.ActiveSheet.Range("N1:N65000").Find(What:=Membre, LookAt:=2, SearchOrder:=2, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)

Because if I comment this, the process vanish

But I don't know why

Please help-me !


Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
No solutions for my find ?

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
No solutions for my find ?

Following this post: macro-copying-data-from-excel-rumba-8-1

 

I have a question. I find how make a search of value in EXCEL in script RUMBA. I try this but nothing :

'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim XLBook As Object
Dim XLSheet As Object
Dim XLRange As Object
Set XLApp = CreateObject("Excel.Application")  
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "MyEXCEL.xlsx"  
SysDelay 1  
Set MYBook = XLApp.Workbooks("MyEXCEL.xlsx")
Set XLSheet = MYBook.Worksheets("Feuil1")
'Set XLSheet2 = MYBook.Worksheets("Feuil2")
Set XLRange = XLSheet.Range("A1:A20")
XLRange.ColumnWidth = 17
XLSheet.Activate
XLSheet.Select
   Cells.Find(What:="aaa", After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

 

If I add "XLSheet" in front "Cells.Find......". I have a error : Type mismatch

 

And trying :

 

Dim retour
set retour = Range.Find(What:="labourier", LookAt _
        :=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
print retour.address

 

But this return always $1:$1048576

 

Can you help me PLZ ?

 

I found how read a cell EXCEL :

Dim Mydata As variant

  MyData = XLSheet.Range("B11").Value                ' put data into a variable

MsgBox MyData


#Rumba
Hi Patrick,

I've been able to reproduce this behaviour when using the Rumba Engine. I've no idea what the root cause of the issue is, but it certainly looks like something in our Engine and not dealing with the cleaning up of the range (FoundCell). I am unable to reproduce the issue when using VBA in Reflection (16.1) or Outlook (2013).

I've taken your code from earlier in the thread and have it working in RUMBA Script (below) using the SendMessage function to force Excel to close.

Personally I'd just run with this approach. First do and XLApp.Quit then send the WM_Close message to the Excel Window handle.

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Const WM_CLOSE = &H10

Sub Main
'Lancement d'1 fichier EXCEL
Dim XLApp As Object
Dim MyBook As Object
Dim XLBook As Object
Dim XLSheet As Object
'Dim XLRange As Object
Dim Range As Object
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = True
XLApp.Workbooks.Open Filename:= "monfic.xlsx" '''', ReadOnly:=True
SysDelay 1
Set MYBook = XLApp.Workbooks("monfic.xlsx")
Set XLSheet1 = MYBook.Worksheets("Sheet1")
Set XLSheet2 = MYBook.Worksheets("Sheet2")

Membre = "aaaaa"
XLSheet2.Activate
Dim FoundCell as Object
set FoundCell = MYBook.ActiveSheet.Range("A1:ZZ100000").Find(What:=Membre, LookAt:=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then
XLSheet1.Activate
set FoundCell = MYBook.ActiveSheet.Range("A1:ZZ100000").Find(What:=Membre, LookAt:=2, SearchOrder:=1, SearchDirection:=1, MatchCase:=False, SearchFormat:=False)
If FoundCell Is Nothing Then
NonTrouvé = True
print "nontrouvé : " & NonTrouvé
Else
MsgBox "Nom de la feuille active : " & MYBook.ActiveSheet.Name
print FoundCell.address
print FoundCell.value
End If
Else
MsgBox "The name of the active sheet is " & MYBook.ActiveSheet.Name
print FoundCell.address
print FoundCell.value
End If

'XLSheet1.Application.Quit ' Close the EXCEL sheet
XLApp.Workbooks("monfic.xlsx").Close SaveChanges:=False

Set XLSheet1 = Nothing ' Release all EXCEL Objects
Set XLSheet2 = Nothing
Set XLSheet3 = Nothing
Set XLSheet4 = Nothing
Set XLBook = Nothing

XLApp.Quit
Set XLApp = Nothing

SendMessage Findwindow("XLMAIN", "Excel"), WM_CLOSE, 0, 0
stop
End Sub