Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / September 2006

Tip: Looking for answers? Try searching our database.

Application-defined or object-defined error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Glenn Mulno - 08 Sep 2006 18:28 GMT
Hi,

I find myself stumped by an incredibly easy piece of code and one that I
have used before.

I am getting the error:
Run-time error '1004':
Application-defined or object-defined error

I am getting the error when I run the following code:

Private Sub Workbook_Open()

With Application
   .ScreenUpdating = False
   .DisplayAlerts = False

   Workbooks.Open
"\\depot02\rel\www\internal\business_areas\edg\Metrics\Phones\HighHoldTimesDetailed.xls"
   Workbooks("HighHoldTimesDetailed.xls").Worksheets("data").Cells.Copy _
   Workbooks("phoneholdtimes.xls").Worksheets("data").Cells
   'error happens on above line(multi line)

   Workbooks("HighHoldTimesDetailed.xls").Close False
   .ScreenUpdating = True
   .DisplayAlerts = True
   .ActiveWorkbook.Saved = True
End With

'Worksheets("data").Activate
Worksheets("Team Graphs - Combined").Activate

End Sub

This runs when the file opens.  The point of it is to copy a worksheet from
one file into the current file.

It opens the source file ok but chokes on the actual copy command. I do not
understand why.  I have used the above lines of code many many times in many
files to copy worksheets from one workbook to another and have never had a
problem before.

The only difference than before is the location of the source file, normally
when I run this set of commands the source and destination files are in the
same directory. But the code opened the source file ok, so I do not think it
is that.

Also - I know the source file has a lot of data on the worksheet "data".

Is there something obvious I messed up here? Some blatant typo?

Thanks in advance for another set of eyes!

Signature

Glenn

Huff - 11 Sep 2006 11:12 GMT
Glenn

I'd guess that you need to tell Excel where the destination file is
stored, otherwise it'll be looking in the same directory as the source.

Cheers

Doug

Rate this thread:






 
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.