Solved

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

Posted on 2004-04-14
6
166 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now