Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy sheet from workbook in new instance of Excel

I am trying to copy sheet from another workbook opened in a new instance of
excel. I need to do it as a new instance as I do not want the user to see
the other workbook being opened (and I will run a progress meter as many
workbooks have to be opened and checked). Code is

Dim xlBack As Excel.Application
Dim wbkOpened As Workbook
Dim wbkThis As Workbook

Dim strFolder As String

Set wbkThis = Application.ActiveWorkbook
Set xlBack = New Excel.Application 'Open in the background
strFolder = strNameThisWbk("F") 'My function to get the current folder
Set wbkOpened = xlBack.Workbooks.Open(strFolder & "\" & "Test1.xls", False,
True)
xlBack.Visible = True 'Make visible during debug
wbkOpened.Sheets(1).Copy Befo=wbkThis.Sheets(1)

This fails on the last line with "Copy method of Worksheet class failed"
--
Mining
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Copy sheet from workbook in new instance of Excel

You can copy sheet and paste to another workbook---All within the same
instance of excel...

If this post helps click Yes
---------------
Jacob Skaria


"selcast" wrote:

I am trying to copy sheet from another workbook opened in a new instance of
excel. I need to do it as a new instance as I do not want the user to see
the other workbook being opened (and I will run a progress meter as many
workbooks have to be opened and checked). Code is

Dim xlBack As Excel.Application
Dim wbkOpened As Workbook
Dim wbkThis As Workbook

Dim strFolder As String

Set wbkThis = Application.ActiveWorkbook
Set xlBack = New Excel.Application 'Open in the background
strFolder = strNameThisWbk("F") 'My function to get the current folder
Set wbkOpened = xlBack.Workbooks.Open(strFolder & "\" & "Test1.xls", False,
True)
xlBack.Visible = True 'Make visible during debug
wbkOpened.Sheets(1).Copy Befo=wbkThis.Sheets(1)

This fails on the last line with "Copy method of Worksheet class failed"
--
Mining

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Copy sheet from workbook in new instance of Excel

This fails on the last line with "Copy method of Worksheet class failed"

If this does turn out to not be possible, could you create a new
sheet, and select / copy / paste the contents across? This is probably
more reliable than using the Sheets.Copy function as that truncates
cells to 255 characters.

Phil Hibbs.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Copy sheet from workbook in new instance of Excel

if you turn screen updating off
Application.ScreenUpdaing = false
then you can open the workbook in the same excel instance ...


"selcast" wrote:

I am trying to copy sheet from another workbook opened in a new instance of
excel. I need to do it as a new instance as I do not want the user to see
the other workbook being opened (and I will run a progress meter as many
workbooks have to be opened and checked). Code is

Dim xlBack As Excel.Application
Dim wbkOpened As Workbook
Dim wbkThis As Workbook

Dim strFolder As String

Set wbkThis = Application.ActiveWorkbook
Set xlBack = New Excel.Application 'Open in the background
strFolder = strNameThisWbk("F") 'My function to get the current folder
Set wbkOpened = xlBack.Workbooks.Open(strFolder & "\" & "Test1.xls", False,
True)
xlBack.Visible = True 'Make visible during debug
wbkOpened.Sheets(1).Copy Befo=wbkThis.Sheets(1)

This fails on the last line with "Copy method of Worksheet class failed"
--
Mining

Reply
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
Finding every instance of a value in a multi-sheet workbook Maury Markowitz[_2_] Excel Programming 6 July 3rd 08 05:44 PM
copy one sheet to other excel workbook Narendra Boga[_2_] Excel Discussion (Misc queries) 3 June 11th 07 11:06 AM
Get Workbook path but from another excel instance [email protected] Excel Programming 4 March 19th 07 05:18 PM
Run Macro in another workbook already OPENED in another instance of Excel [email protected] Excel Programming 3 December 27th 06 04:37 AM
How do I copy an entire worksheet to another instance of excel? Alan Excel Programming 7 June 30th 05 06:06 AM


All times are GMT +1. The time now is 10:40 PM.

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"