Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data spread in an Excel template

Status
Not open for further replies.

loulouly

IS-IT--Management
Jul 17, 2003
6
US
Hi, I have a program in VBA that spreads data in a Excel file... this program create automaticly the Excel file. What I would like is that this program, instead of creating a new excel file, just uses an Excel template I have created.
do you know how to do that?

Thanx

Ly
 
Whats your code? Thinking son the lines of adding something like Workbooks.Add Template:= _
"C:\Program Files\Microsoft Office\Templates\1033\yourtemplate.xlt" to your macro

Just an idea
 
Whats your code? Thinking on the lines of adding something like Workbooks.Add Template:= _
"C:\Program Files\Microsoft Office\Templates\1033\yourtemplate.xlt" to your macro

Just an idea
 
here a part of the source code:
(how can I specify that I want my template instead of the excel sheet it creates?)

Sub makefile()
On Error Resume Next
Dim X As Object
Set X = CreateObject("excel.sheet")
X.Application.Visible = True
X.Application.Range("A1").Select
X.Application.ActiveCell.FormulaR1C1 = "Tranmission Loss Measurement"
X.Application.Range("A2").Select
X.Application.ActiveCell.FormulaR1C1 = "Date"
X.Application.Range("B2").Select
X.Application.ActiveCell.FormulaR1C1 = MeasureForm.DateText.Text
X.Application.Range("A3").Select
X.Application.ActiveCell.FormulaR1C1 = "Test Identification:"
X.Application.Range("B3").Select
X.Application.ActiveCell.FormulaR1C1 = MeasureForm.TestIdentText.Text
X.Application.Range("A4").Select
X.Application.ActiveCell.FormulaR1C1 = "Calibration File:"
X.Application.Range("B4").Select
X.Application.ActiveCell.FormulaR1C1 = CalFileToOpen
X.Application.Range("A5").Select
X.Application.ActiveCell.FormulaR1C1 = "Measurement Data File:"
X.Application.Range("B5").Select
X.Application.ActiveCell.FormulaR1C1 = MeasFileToOpen
X.Application.Range("A7").Select
X.Application.ActiveCell.FormulaR1C1 = "Operating Conditions:"
X.Application.Range("A8").Select
X.Application.ActiveCell.FormulaR1C1 = "Microphone Spacing (in)"
X.Application.Range("B8").Select
X.Application.ActiveCell.FormulaR1C1 = MeasureForm.MicSpacing.Text
X.Application.Range("A9").Select
X.Application.ActiveCell.FormulaR1C1 = "Flow rate (scfm)"
X.Application.Range("B9").Select
X.Application.ActiveCell.FormulaR1C1 = MeasureForm.FlowrateText.Text
X.Application.Range("A10").Select
X.Application.ActiveCell.FormulaR1C1 = "Upstream pipe diameter(in)"
X.Application.Range("B10").Select
X.Application.ActiveCell.FormulaR1C1 = MeasureForm.UpstreamDia.Text
X.Application.Range("A11").Select
X.Application.ActiveCell.FormulaR1C1 = "Downstream pipe diameter (in)"
X.Application.Range("B11").Select
X.Application.ActiveCell.FormulaR1C1 = MeasureForm.DownstreamDia.Text
X.Application.Range("A12").Select
X.Application.ActiveCell.FormulaR1C1 = "Temperature (F)"
X.Application.Range("B12").Select
X.Application.ActiveCell.FormulaR1C1 = MeasureForm.Temperature.Text
X.Application.Range("A13").Select
X.Application.ActiveCell.FormulaR1C1 = "Frequnecy Start (Hz)"
X.Application.Range("B13").Select
X.Application.ActiveCell.FormulaR1C1 = Freq(1)
X.Application.Range("A14").Select
X.Application.ActiveCell.FormulaR1C1 = "Frequency End (Hz)"
X.Application.Range("B14").Select
X.Application.ActiveCell.FormulaR1C1 = Freq(NPoints)
X.Application.Range("A15").Select
X.Application.ActiveCell.FormulaR1C1 = "Number of Points"
X.Application.Range("B15").Select
X.Application.ActiveCell.FormulaR1C1 = NPoints

X.Application.ActiveSheet.Columns("A:A").ColumnWidth = 27#
X.Application.ActiveSheet.Rows("4:4").RowHeight = 25
X.Application.ActiveSheet.Rows("5:5").RowHeight = 25
X.Application.ActiveSheet.Columns("B:B").ColumnWidth = 50#

X.Application.ActiveSheet.Range("B4").WrapText = True
X.Application.ActiveSheet.Range("B5").WrapText = True
On Error Resume Next ' In case printer is not available
'X.Application.ActiveSheet.PrintOut

X.Application.Sheets.Add
X.Application.Cells(1, 1).Value = "Transmission Loss Characteristics"
X.Application.ActiveSheet.Cells(2, 1).Value = "Frequency(Hz)"
X.Application.ActiveSheet.Cells(2, 2).Value = "Transmission Loss (dB)"
 
Don't know how to apply a template to an existing w/b so try using the Workbooks.Add Template:= blah blah before your code else someone else help pls??? Sorry I haven't your answer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top