Solved

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

Posted on 2004-04-14
6
169 Views
Last Modified: 2010-04-05
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
0
Comment
Question by:mikelittlewood
  • 3
  • 3
6 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 100 total points
ID: 10824166
oxl.WorkBooks.Open('C:\Test.xls');
0
 
LVL 15

Author Comment

by:mikelittlewood
ID: 10824566
ah fantastic ... thought it might be something really easy ... still trying to understand automation, this is only my first attempt  :)
0
 
LVL 15

Author Comment

by:mikelittlewood
ID: 10824602
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10824817

ExtractFilePath(Application.exename)

Return the path including the backslash so

oxl.WorkBooks.Open(ExtractFilePath(Application.exename) +'Test.xls');
0
 
LVL 15

Author Comment

by:mikelittlewood
ID: 10826732
All works a treat .. thx for your help
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 10826959
glad to have helped you :)
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question