Just starting out? Need help? Post your questions and find answers here.
-
jackymb
- User

- Posts: 16
- Joined: Wed Aug 11, 2004 7:37 pm
- Location: AIX en PROVENCE (France)
Post
by jackymb »
Hi,
I am try READ un Excel File, but Excel Open = Ok, file not appear.
Code: Select all
IncludePath #PB_Compiler_Home + "Include\"
XIncludeFile "COMate.pbi"
intRow.i = 2
Define.COMateObject ExcelObject, WorkBook
ExcelObject = COMate_CreateObject("Excel.Application")
;ExcelObject = GetObjectProperty("Workbooks\Open 'FileName:=Comate.xls'")
ExcelObject\SetProperty("Visible = #True")
ExcelObject\GetObjectProperty("Workbooks\Open 'FileName:=ComateTest.xls'")
If ExcelObject
MessageRequester("COMate -Excel demo", "" )
; Repeat
; MessageRequester("",ExcelObject\GetStringProperty("Cells(intRow,1)"))
; intRow = intRow + 1
; Until ExcelObject\GetStringProperty("Cells(intRow,1) = ''")
ExcelObject\Invoke("Quit()")
ExcelObject\Release()
Else
MessageRequester("COMate -Excel demo", "Couldn't create the application object!")
Please HelpMe
-
Kiffi
- Addict

- Posts: 1487
- Joined: Tue Mar 02, 2004 1:20 pm
- Location: Amphibios 9
Post
by Kiffi »
jackymb wrote:Code: Select all
ExcelObject\GetObjectProperty("Workbooks\Open 'FileName:=ComateTest.xls'")
Code: Select all
ExcelObject\Invoke("Workbooks\Open('[YourFullPathHere]\ComateTest.xls')")
Greetings ... Kiffi
Hygge
-
srod
- PureBasic Expert

- Posts: 10589
- Joined: Wed Oct 29, 2003 4:35 pm
- Location: Beyond the pale...
Post
by srod »
Ack Kiffi is too fast!
Code: Select all
WorkBook = ExcelObject\GetObjectProperty("Workbooks\Open('c:\test.xls')")
I may look like a mule, but I'm not a complete ass.
-
jackymb
- User

- Posts: 16
- Joined: Wed Aug 11, 2004 7:37 pm
- Location: AIX en PROVENCE (France)
Post
by jackymb »
Thanks Kiffi & Srod
another question: how to read a string in a cell, which increases the index intRow
Code: Select all
intRow.i = 2
Repeat
Cell$ = ExcelObject\GetStringProperty("Cells(intRow,1)")
MessageRequester("Row: " + Str(intRow),Cell$)
intRow = intRow + 1
Until ExcelObject\GetStringProperty("Cells(intRow,1) = #nullstring")
-
Kiffi
- Addict

- Posts: 1487
- Joined: Tue Mar 02, 2004 1:20 pm
- Location: Amphibios 9
Post
by Kiffi »
Code: Select all
Cell$ = ExcelObject\GetStringProperty("Cells(" + Str(intRow) + ",1)")
(same in your Until - Statement)
Greetings ... Kiffi
Hygge
-
jackymb
- User

- Posts: 16
- Joined: Wed Aug 11, 2004 7:37 pm
- Location: AIX en PROVENCE (France)
Post
by jackymb »
Thank you very much Kiffi.
It's really stupid to have forgotten that ir string.
-
Pierre Mercier
- User

- Posts: 10
- Joined: Wed Apr 23, 2008 4:02 am
- Location: CANADA
Post
by Pierre Mercier »
I tried that code on Excel 2007 wrote by Jackymb, corrected by Kiffi and srod. It worked until
this line
Code: Select all
until Cell$ = ExcelObject\GetStringProperty("Cells(" + Str(intRow) + ",1) = #NullString")
To make it worked i replace it with
Is it working with another excel version.
Also how can i put a header and footer ?
-
srod
- PureBasic Expert

- Posts: 10589
- Joined: Wed Oct 29, 2003 4:35 pm
- Location: Beyond the pale...
Post
by srod »
Code: Select all
until Cell$ = ExcelObject\GetStringProperty("Cells(" + Str(intRow) + ",1) = #NullString")
That line makes no sense whatsoever and does not represent a valid COMate command string.
I may look like a mule, but I'm not a complete ass.