How do I change the code I have to open an existing excel temple I have saved

I want to open an existing excel template I have so I can enter some values from my database into the active sheet.

  oXL := CreateOleObject('Excel.Application');
  oXL.Visible := True;

  // Get a new workbook
  oWB := oXL.Workbooks.Add;
  oSheet := oWB.ActiveSheet;

How can I change the line oXL.Workbooks.Add for my standard .xls file
LVL 15
mikelittlewoodAsked:
Who is Participating?
 
Ferruccio AccalaiConnect With a Mentor Senior developer, analyst and customer assistance Commented:
oxl.WorkBooks.Open('C:\Test.xls');
0
 
mikelittlewoodAuthor Commented:
ah fantastic ... thought it might be something really easy ... still trying to understand automation, this is only my first attempt  :)
0
 
mikelittlewoodAuthor Commented:
In fact while I have your attention :)

if I wanted to place my template doc in the same folder as my delphi app, do I still have to use c:\<Filename> or is there a standard string I can use to say "Look in application directory"
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:

ExtractFilePath(Application.exename)

Return the path including the backslash so

oxl.WorkBooks.Open(ExtractFilePath(Application.exename) +'Test.xls');
0
 
mikelittlewoodAuthor Commented:
All works a treat .. thx for your help
0
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
glad to have helped you :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.