By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

Excel automation weirdness

P: n/a
I trying to create an Excel workbook from Access and then do some formatting
of the workbook. I did quite a bit of this with Access 97 a few years back,
but I haven't done much with A2K. So I created some basic code (below) to
get me up and running. But it just bounces out of the formatting sub with no
errors. If I compact the DB, it works once and then stops working again.

Can anyone see any obvious bugs with the snippet below or explain this
issue. I going to move the formatting code to an Excel macro for now, but
I'd like to know what's going on.


Set xlApp = xlBook.Application
'xlApp.Visible = False
'xlApp.ScreenUpdating = False

Set xlSheet = xlApp.Workbooks(1).Worksheets(1)
xlSheet.Activate
'Set UR = xlSheet.UsedRange

'Find our working Range
xlApp.Cells(4, 2).Select
xlApp.Range(Selection, Selection.End(xlDown)).Select
The code returns to the calling sub here (above) with no error, unless I
compile the db and then only works once.

xlApp.Range(Selection, Selection.End(xlRight)).Select
Set UR = Selection
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi!

This line:

xlApp.Range(Selection, Selection.End(xlDown)).Select

is using unqualified references to Excel objects, and is very likely to

cause the anomality you're experiencing. Try qualifying:

xlApp.Range(xlApp.Selection, xlApp.Selection.End(xlDown)).Select

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.