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: 10
Default Copying across workbooks

I am working from Access and trying to copy and paste data between two
workbooks.



' Create a new instance of Excel
Set xlApp = New Excel.Application

' Make it visible
xlApp.Visible = True

' Open an associated file
Set xlWorkBook1 = xlApp.Workbooks.Open(strInputFileName)

' download Access Query to excel in same folder as associated file

strInputFilePath = xlWorkBook1.Path
DoCmd.TransferSpreadsheet acExport, 8, "tbl99ReconRepBase",
strInputFilePath & "\sheet15temp.xls"

' Open the downloaded file
Set xlWorkBook2 = xlApp.Workbooks.Open(strInputFilePath &
"\sheet15temp.xls")

' copy some data over

xlWorkBook1.Activate
etc ....

This seems to work fine except if Excel is already open. In which case it
gives an error on the last line
Run time error 1004
Method 'Sheets' of object Global failure

I have declared xlWorkbook1,2 as workbooks. Any suggestions please
 
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
Copying between workbooks Brad Excel Discussion (Misc queries) 2 January 9th 08 08:22 PM
Copying workbooks Nadji New Users to Excel 4 October 5th 06 03:16 PM
Copying from other Workbooks SusieQ Excel Discussion (Misc queries) 0 January 30th 06 12:44 PM
need help for copying among workbooks snow Excel Programming 1 March 26th 05 12:26 PM
Copying from several workbooks into one Anthony Gobel Excel Programming 0 April 6th 04 09:56 PM


All times are GMT +1. The time now is 04:14 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"