Solved

How do I freeze panes in Excel using Delphi and OLE

Posted on 2010-09-01
9
1,937 Views
Last Modified: 2012-05-10
I've got most of it (creating a excel sheet from Delphi) working but can't find the correct
 wording for freezing panes.

I'd also like to be able to use validation on cells.

Is there a good resource that I can find this info for myself?
0
Comment
Question by:s_w_e2
  • 4
  • 3
  • 2
9 Comments
 
LVL 9

Expert Comment

by:javajws
ID: 33583532
0
 
LVL 9

Expert Comment

by:javajws
ID: 33583542
0
 

Author Comment

by:s_w_e2
ID: 33583549
I'm not sure how to do the above solutions in Delphi.
0
 
LVL 13

Expert Comment

by:aflarin
ID: 33583878
>> Is there a good resource that I can find this info for myself?

At first you can import Excel library (Project -> Import Type Library -> Microsoft Excel Object Library)
Then you can look at the imported code and find things like consts, param counts etc

At the second you can use MSDN to find description of all Excel interfaces and objects. For example here is description of FormatConditions.Add method:

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.formatconditions.add(office.11).aspx
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 13

Accepted Solution

by:
aflarin earned 500 total points
ID: 33583900
>> I'm not sure how to do the above solutions in Delphi.

procedure TForm1.Button1Click(Sender: TObject);
var
  XLApp: Variant;
begin
  XLApp:=CreateOLEObject('Excel.Application');
  XLApp.Visible:= True;
  XLApp.Range['A2:A2'].Select;
  XLApp.ActiveWindow.FreezePanes:= True;
end;
0
 
LVL 13

Expert Comment

by:aflarin
ID: 33583934
Validation:


procedure TForm1.Button1Click(Sender: TObject);
const
  xlValidateWholeNumber = $00000001;
  xlValidAlertInformation = $00000003;
  xlBetween = $00000001;
var
  XLApp: Variant;
  Validation: Variant;
begin
  XLApp:=CreateOLEObject('Excel.Application');
  XLApp.Visible:= True;
  Validation:= XLApp.Range['A1'].Validation;
  Validation.Add( xlValidateWholeNumber, xlValidAlertInformation, xlBetween, 5, 10 );
  Validation.InputTitle := 'Integers';
  Validation.ErrorTitle := 'Integers';
  Validation.InputMessage := 'Enter an integer from five to ten';
  Validation.ErrorMessage := 'You must enter a number from five to ten';
end;
0
 

Author Closing Comment

by:s_w_e2
ID: 33593353
Is there some source where I can find this info for myself?
0
 

Author Comment

by:s_w_e2
ID: 33593366
Sorry for the comment.  I'd missed your first reply.
0
 

Author Comment

by:s_w_e2
ID: 33593501
In the validation piece I needed to add
Validation.ShowError := True;
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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

20 Experts available now in Live!

Get 1:1 Help Now