Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using OLE application
Message
From
05/07/2001 04:37:24
 
 
To
05/07/2001 04:05:40
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00526632
Message ID:
00526851
Views:
16
Budianto,
In addition to Cetin's suggestions, the easiest way IMO to get the VBA syntax is to record a macro in Excel and then examine the generated VBA code. It's fairly simple to convert the VBA code to VFP. You will note that VBA makes extensive use of constants. You need to define these in VFP. You can use the VBA object browser to get the values of the constants and then create #DEFINEs in VFP or create an include file. You may even find an include file in the download section.
The following code shows you how to use Excel's autofit and how to align text:
#DEFINE xlLeft       1
#DEFINE xlCenter -4108
#DEFINE xlRight  -4152
oXls=CREATEOBJECT("excel.application")
oWorkBook = oXLS.Application.Workbooks.add()
oXls.visible=.t.
oXls.activesheet.range("A1").value = "Short text"
oXls.activesheet.range("A2").value = "Some loooooooooooooong text"
oXls.columns().autofit()
oXls.activesheet.range("A1").alignement = xlRight && cell only
oXls.activesheet.columns(1).alignement = xlRight && entire column
*-- etc...
HTH
>>Budianto,
>>IMHO easiest is to use one of predefined formats.
>>
Use customer
>>Copy to customerxls type xls
>>
>>#include xlconstants.h
>>oExcel=createobject('Excel.Application')
>>With oExcel
>>  .Workbooks.Open(sys(5)+curdir()+'customerxls.xls')
>>  With .ActiveWorkBook.ActiveSheet
>>    .Range("A1").AutoFormat(xlRangeAutoFormatColor2)
>>*!*	    *Format headers
>>*!*	    .Cells(1,1).VALUE = "Customer Id"
>>*!*	    * Format the data
>>*!*	    .RANGE("1:1").FONT.Bold=.T.
>>*!*	    .RANGE("L:L").NumberFormat = [_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)]
>>*!*	    With .Range('A:A').Font
>>*!*	      .Bold = .t.
>>*!*	      .Size = 12
>>*!*	      .Color = rgb(255,0,0)
>>*!*	    Endwith
>>*!*	    With .Range('B:B').Font
>>*!*	      .Bold = .t.
>>*!*	      .Italic=.t.
>>*!*	      .Size = 12
>>*!*	      .Color = rgb(0,0,255)
>>*!*	    Endwith
>>*!*	    With .Range('E:E').Font
>>*!*	      .Bold = .t.
>>*!*	      .Italic=.t.
>>*!*	      .Size = 12
>>*!*	    Endwith
>>*!*	    .Columns.Autofit
>>    .Range("A1").select
>>  Endwith
>>  .visible = .t.
>>Endwith
>>
Comment autoformat line and uncomment the commented to see custom formatting.
>>Cetin
>
>
>Thank you very much, Cetin, it work very well, but I still can't find the way to make a line or a box and to align a text in a column.
>btw, where can I find this Excel setting in Visual Foxpro ?
>
>TIA
>
>Budianto
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform