Solved

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

Posted on 2004-04-14
6
167 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

939 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

3 Experts available now in Live!

Get 1:1 Help Now