Hi Gary,
I recommend that you NEVER rely on Excel's ActiveXxxxx objects when automating.
These objects (along with Application.Selection) are designed to reflect the current state of the user interface. When automating, you do not have a user interface, so you are much better to define explicit objects to reference the Workbook/Sheet/range you are working with:
Dim oXLApp As Excel.Application
Dim oXlDoc As Excel.WorkBook
Dim oXlSheet As Excel.WorkSheet
Set oXlApp = CreateObject("Excel.Application")
Set oXLDoc = oXlApp.Workbooks.Add
Set oXLSheet = oXLDoc.Sheet(1)
… then do things with oXLSheet, not oXLApp.ActiveSheet
Best wishes,
Graham Mandeno [Access MVP since 1996]
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Friday, 6 March 2015 10:29
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] Working with Excel tabs
Hi Gary,
I'm not sure if adding a new sheet through code makes it the active sheet or not. If it doesn't you will have to make the newly added sheet active before you start populating it.
Also, please try to remember to click the Show message history link just above the Send button when replying through the web interface. That way, we don't have to search through the messages in case you refer to something earlier in the thread.
Darrell
---In MS_Access_Professionals@yahoogroups.com, <quigonn@...> wrote :
So, when I add a new sheet, Access will use that one until I add a new one?
Thanks,
Gary
Posted by: "Graham Mandeno" <graham@mandeno.com>
| Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (6) |
Tidak ada komentar:
Posting Komentar