Using the MS help site I've used the code below to create a spreadsheet, insert data into specific cells and then produce the result of a calculation on the data I've input into another specific cell :-
Function ExcelTest()
Dim xlobject As Object, xlsheet As Object
Set xlobject = CreateObject("excel.sheet.5"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set xlsheet = xlobject.Application.activeworkbook.sheets("sheet1"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
With xlsheet
.range("b3"
.Value = CDbl(InputBox("Enter 1st Number", "Excel Example"
)
.range("c3"
.Value = CDbl(InputBox("Enter 2nd Number", "Excel Example"
)
.range("d3"
.Value = xlsheet.range("b3"
.Value * xlsheet.range("c3"
.Value
End With
xlsheet.Parent.SaveAs "c:\temp\xltest.xls"
xlobject.Application.Quit
Set xlobject = Nothing
End Function
My question is this:-
I don't want to create a new spreadsheet as this code is doing but I want to open a ready made spreadsheet template (c:\temp\xltest.xlt). I've toyed around with the GetObject function instead of the CreateObject function but I'm loosing the battle.
Does anyone have any suggestions??
Steady ...![[thumbsup2] [thumbsup2] [thumbsup2]](/data/assets/smilies/thumbsup2.gif)
Function ExcelTest()
Dim xlobject As Object, xlsheet As Object
Set xlobject = CreateObject("excel.sheet.5"
Set xlsheet = xlobject.Application.activeworkbook.sheets("sheet1"
With xlsheet
.range("b3"
.range("c3"
.range("d3"
End With
xlsheet.Parent.SaveAs "c:\temp\xltest.xls"
xlobject.Application.Quit
Set xlobject = Nothing
End Function
My question is this:-
I don't want to create a new spreadsheet as this code is doing but I want to open a ready made spreadsheet template (c:\temp\xltest.xlt). I've toyed around with the GetObject function instead of the CreateObject function but I'm loosing the battle.
Does anyone have any suggestions??
Steady ...
![[thumbsup2] [thumbsup2] [thumbsup2]](/data/assets/smilies/thumbsup2.gif)