LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Very Basic Excel Object Questions

An old Cobol guy playing around with VB 3.0 and Excel (Office 2K) needs help
on his first OO program, which is simply reading-only the contents of an
..xls file. I have two simple issues:

1) Wrap-up - I see code examples for closing workbooks, quitting
objects and setting objects to nothing. What is the proper way to wrap up
everything when the I'm done with my objects/files? In using the following
code, I cannot get the Close workbook to execute without either a syntax
error or Method not appl for this object. An instance of Excel is left
running when my program is done (I see it doing ctrl-alt-del and it's got a
hold of the cfe.xls file, too).

Dim xExcelApp As object
Dim xWorkbook As object
Dim xSheet As object
Set xExcelApp = GetObject("", "Excel.Application")
Set xWorkbook = xExcelApp.Workbooks.Open("c:\cfe.xls")
Set xSheet = xWorkbook.Worksheets(form1.Text1) (Text1 has worksheet name)
DO MY THING. . .
WrapUp:
' Release resources
'xExcelApp.Workbooks(1).Close(), tried it w/o the (1) and/or w/o the
(), tried as xWorkbook.Close(), w/o the () and even with the () filled in
with SaveChanges:=False -- hurumph!! -- nothing works.
Set xExcelApp = Nothing
Set xWorkbook = Nothing
Set xSheet = Nothing -- what does Quit do for me? Will
doing something at the xExcelApp level take care of
everything
underneath?

2) During the DO MY THING above, the 'If xSheet.Cells(i, j) = "" Then'
statement errors with err=437 whenever the cell is empty. Since I have on
error resume next, when the error occurs it falls to the next statement -
which is what I want it to do in this example anyway, but coding based on
receiving this error for empty cells seems ridiculous to me, especially if
what I really want to code is 'If xSheet.Cells(i, j) = "something besides
nulls". Any ideas?

Otherwise, I'm having fun again and I've used the worksheet values to
create an Outlook email item and send it! Any help for these elementary
issues with Excel and in general, wrapping up, is greatly appreciated.






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
call Module from MS Excel Object - Probably very easy VB questions Kevin Excel Discussion (Misc queries) 4 January 4th 08 02:32 AM
Inserting a MS Word object into an Excel spreadsheet (2 questions) Phrank Excel Worksheet Functions 1 December 28th 07 02:22 PM
Basic questions Maine begins Excel Discussion (Misc queries) 1 July 7th 06 06:45 PM
2 basic Excel questions for you pro's cjtj4700 Excel Discussion (Misc queries) 7 November 24th 05 07:31 PM
EXCEL Visual Basic Questions Dean[_8_] Excel Programming 3 May 9th 05 09:03 PM


All times are GMT +1. The time now is 08:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"