Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / August 2005

Tip: Looking for answers? Try searching our database.

Copy worksheet in ACCESS Code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marjie - 05 Aug 2005 15:51 GMT
From my Access 2000 application I am opening an Excel workbook which starts
with 10 worksheets (used for other purposes).  The second sheet is used to
display projects.  I am adding(appending) additional worksheets as needed
depending on the number of projects encountered in my Access table.  

The code runs fine, the first time, but when I run it a second time, I get
an error: "Application defined or Object defined error".  If I close the
access database and open it again, the code will run the first time I click
on the button which runs the code, but errors out the second time I try to
run it.  Can anyone help??  Here is the pertinent part of my code (I've
editted it to remove extraneous code that checks for every 10 projects) The
error occurs on the .sheets(2)copy...etc line :

Set appXl = GetObject("Excel.Application")
With appXl
   Set objWkb = .Workbooks.Open(lstrTempWkbName)
  .Sheets(2).Copy after:=Sheets(10)          '*This is the line that errors
  .....  here I do the display of project information
  .Workbooks.Close    
End With

Close_Out:
     appXl.Quit
     Set appXl = Nothing      
Klatuu - 05 Aug 2005 16:59 GMT
I don't see anything obvious, but I do notice you don't destroy the objWkb
object.  See code added below:

> From my Access 2000 application I am opening an Excel workbook which starts
> with 10 worksheets (used for other purposes).  The second sheet is used to
[quoted text clipped - 19 lines]
> Close_Out:
>       appXl.Quit
        set objWkb = Nothing
>       Set appXl = Nothing
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.