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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a Spreadsheet

Status
Not open for further replies.

solo7

Technical User
Mar 14, 2001
243
NO
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")
Set xlsheet = xlobject.Application.activeworkbook.sheets("sheet1")

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]
 
Set appword = CreateObject("word.application")
appword.Visible = True
'Open the selected merge-document
appword.Documents.Open strWordDoc

I've not test it for Excel, but in Word it's working. I think it also does in Excel, strWordDoc is the full pathname of youre template "C:\test.xls" or something

If it's not working, come back to me and I will look further
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top