Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to know an Excel spreadsheet is empty
Message
From
07/12/2002 17:34:22
 
 
To
07/12/2002 17:22:30
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00730656
Message ID:
00730661
Views:
9
This message has been marked as a message which has helped to the initial question of the thread.
lcFile = "MyWorkBook.xls"
oExcel = CreateObject("Excel.Application")
oWorkBook = oExcel.WorkBooks.Open(lcFile)
oSheet = oWorkBook.Sheets(1)
lcUsedRange = oSheet.UsedRange.Location
If lcUsedRange == "$A$1"
* Sheet is Empty
EndIf
*- End of Snippet -*

Maria, this is quick code. I am doing this from memory. If you would like some real code let me know and I will fish through some stuff. If you want to check cell by cell:

oSheet.Cells(nRow,nCol).Value && True value of cell (.Null. is possible)
oSheet.Cells(nRow,nCol).Text && value of cell returned as Character

Let me know if you want me to fill in the blanks with specifics (named files, sheets, etc.)

- David -


>David,
>Yes, a short code example will help me greatly.
>I'm really short of time now, it will great if you can spare me digging on the object model of Excel.
>
>TIA
>
>>You can check the .UsedRange.Address property of the sheet object. It will return $A$1 on an empty sheet or you can check cell by cell. Let me know if you need actual coding. I'm sure this is one of a dozen different methods. This one of the reasons I love UT, you get lots of responses with many different methods (hopefully at least one is new to "you").
>>
>>
>>>I'm working in an import wizard for one of our tables.
>>>
>>>I need to know if an Excel spreadsheet is empty, "empty" is simply defined for this work as the file having empty the first row of the first sheet.
>>>
>>>How can I programatically check it?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform