Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Import worksheets from another workbook? | Excel Worksheet Functions | |||
How do I import one workbook into another? | Excel Discussion (Misc queries) | |||
Need to IMPORT a Worksheet From another WorkBook | Excel Worksheet Functions | |||
Import Data from the Same Workbook | Excel Discussion (Misc queries) | |||
Conditional import of data from other workbook or worksheet | Excel Discussion (Misc queries) |