Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I import an XLT worksheet into another workbook?

I'm recording a macro within a particular workbook. I need to (while I'm
still recording) import an XLT (template) worksheet from another workbook
into the one I'm recording on. I can import the data but it loses it's
format and places the data randomly. I need the template to come in as a new
worksheet showing up exactly as it is saved in it's original file.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default How do I import an XLT worksheet into another workbook?

Try opening the template as a file (Workbooks.Open) then copy the sheet from
that new workbook to the main book, and close the XLT book.

On Tue, 4 Oct 2005 14:34:03 -0700, chris5
wrote:

I'm recording a macro within a particular workbook. I need to (while I'm
still recording) import an XLT (template) worksheet from another workbook
into the one I'm recording on. I can import the data but it loses it's
format and places the data randomly. I need the template to come in as a new
worksheet showing up exactly as it is saved in it's original file.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default How do I import an XLT worksheet into another workbook?

Chris:

Below is some sample code which accomplishes this task. It assume the
template workbook is not open currently.

Public Sub CopyWorksheet()
Dim wkb As Workbook

Set wkb = Workbooks.Open("c:\MyTemplateWorkbook.xlt")

wkb.Worksheets("MyTemplateWorksheet").Select

wkb.Worksheets("MyTemplateWorksheet").Copy
Befo=Workbooks("MyDestinationWorkbook").Sheets( 1)

Set wkb = Nothing

End Sub

You can also use the Window menu to move to the open template workbook, and
then right-click on the worksheet tab you wish to copy. Select Move or
Copy, and then select the destination workbook in the "To Book" combobox.
Also check the Create a Copy checkbox.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


"chris5" wrote in message
...
I'm recording a macro within a particular workbook. I need to (while I'm
still recording) import an XLT (template) worksheet from another workbook
into the one I'm recording on. I can import the data but it loses it's
format and places the data randomly. I need the template to come in as a
new
worksheet showing up exactly as it is saved in it's original file.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I import an XLT worksheet into another workbook?

You could also just add the sheet from a template workbook.

Dim newWks As Object
Set newWks = Sheets.Add(Type:="C:\my documents\excel\book1.xlt")


chris5 wrote:

I'm recording a macro within a particular workbook. I need to (while I'm
still recording) import an XLT (template) worksheet from another workbook
into the one I'm recording on. I can import the data but it loses it's
format and places the data randomly. I need the template to come in as a new
worksheet showing up exactly as it is saved in it's original file.


--

Dave Peterson
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
Import worksheets from another workbook? bjwheeler Excel Worksheet Functions 1 April 13th 09 05:24 PM
How do I import one workbook into another? jkarennj Excel Discussion (Misc queries) 1 June 26th 08 04:22 PM
Need to IMPORT a Worksheet From another WorkBook Krefty Excel Worksheet Functions 2 October 10th 07 02:34 PM
Import Data from the Same Workbook Ananth Excel Discussion (Misc queries) 1 February 20th 07 01:42 PM
Conditional import of data from other workbook or worksheet Bengt Bergholm Excel Discussion (Misc queries) 1 October 14th 05 12:05 PM


All times are GMT +1. The time now is 12:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"