Solved

Trying to understand microsoft com object

Posted on 2004-04-29
6
385 Views
Last Modified: 2010-04-05
Im currently trying to work out how I can translate what I read in the excel com object in VBA and workout how to call from excel

I can currently open a new workbook and write data to it fine, but now Im trying to work out how to format cells.
For example, a simple underline for a cell, I read in the com object the line
ActiveCell.Font.Underline = xlUnderlineStyleSingle
I tried doing oSheet.Cells[1,1].Font.Underline := xlUnderlineStyleSingle;
where oSheet is my active sheet, and obviously delphi didnt understand xlUnderlineStyleSingle
Does anyone have a place on the web I might be able to find direct translations,
or have a quick-fire method for me to understand
0
Comment
Question by:mikelittlewood
  • 2
  • 2
  • 2
6 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
Comment Utility
0
 
LVL 12

Assisted Solution

by:Ivanov_G
Ivanov_G earned 50 total points
Comment Utility

   also Project / Import Type Library
   select Microsoft Excel 10
   Create Unit

   check if you have

         C:\Program Files\Borland\Delphi7\Ocx\Servers\excel97.pas
0
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 50 total points
Comment Utility
i don't remember where i've found these units for word and excel constants translations for Delphi....BTW i use them succesfull....

unit ExcelConst;

interface

Const
xlCenter=-4108;
xlLeft=-4131;
xlRight=-4152;
xlDistributed=-4117;
xlJustify=-4130;
xlNone=-4142;
{HorizontalAlignment}
xlHAlignCenter=-4108;
xlHAlignDistributed=-4117;
xlHAlignJustify=-4130;
xlHAlignLeft=-4131;
xlHAlignRight=-4152;
{In addition, for the Range or Style object}
xlHAlignCenterAcrossSelection=7;
xlHAlignFill=5;
xlHAlignGeneral=1;

{VerticalAlignment}
xlVAlignBottom=-4107;
xlVAlignCenter=-4108;
xlVAlignDistributed=-4117;
xlVAlignJustify=-4130;
xlVAlignTop=-4160;

{Borders}
xlInsideHorizontal=12;
xlInsideVertical=11;
xlDiagonalDown=5;
xlDiagonalUp=6;
xlEdgeBottom=9;
xlEdgeLeft=7;
xlEdgeRight=10;
xlEdgeTop=8;

{LineStyle}
xlContinuous=1;
xlDash=-4115;
xlDashDot=4;
xlDashDotDot=5;
xlDot=-4118;
xlDouble=-4119;
xlSlantDashDot=13;
xlLineStyleNone=-4142;

{Weight}
xlHairline=1;
xlThin=2;
xlMedium=-4138;
xlThick=4;

{ColorIndex}
xlColorIndexAutomatic=-4105;
xlColorIndexNone=-4142;

{Background}
xlBackgroundAutomatic=-4105;
xlBackgroundOpaque=3;
xlBackgroundTransparent=2;

{Underline}
xlUnderlineStyleNone=-4142;
xlUnderlineStyleSingle=2;
xlUnderlineStyleDouble=-4119;
xlUnderlineStyleSingleAccounting=4;
xlUnderlineStyleDoubleAccounting=5;

implementation

end.

unit WordConst;

interface

Const
{----MoveRight(Unit, Count, Extend)}
{Unit}
wdCharacter=1;
wdWord=2;
wdSentence=3;
wdCell=12;
wdAdjustNone=0;
wdOrientPortrait=0;
wdOrientLandScape=1;
wdAlignParagraphCenter=1;
wdAlignParagraphLeft=0;
wdAlignParagraphRight=2;
{Extend}
wdMove=0;
wdExtend=1;
wdBorderHorizontal=-6;
wdBorderVertical=-5;
wdLineStyleNone=0;
wdLine=5;
implementation

end.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 15

Author Comment

by:mikelittlewood
Comment Utility
Excellent

Combining Ivanov_G
   also Project / Import Type Library
   select Microsoft Excel 10
   Create Unit

and data from Ferruccio68,
I can see where Ferruccio68 got his numbers from (converting the hex value in the excel com object file to decimal)

I havent imported the file Ivanov_G and set it in my uses clause as Im not doing too much, so Im just using the decimal numbers.

Thanks to both, I am spliting the points for the 2 of you.
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
Comment Utility
Glad to have helped you :)

F68 ;-)
0
 
LVL 15

Author Comment

by:mikelittlewood
Comment Utility
I think the hard part for me is that I havent done much COM before.
Trying to work out what calls I need to make from delphi to the com objects is a little difficult.
Not sure if there is an easy way or not.

For example, took me a while just to work out how to make a cell bold (lol)
And that was only because I stumbled on an example.
sheet.cell.font.fontstyle := bold;
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

11 Experts available now in Live!

Get 1:1 Help Now