Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to protect an Excel column ???
Message
De
27/02/2007 08:20:04
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
27/02/2007 05:28:37
Albert Beermann
Piepenbrock Service Gmbh & Cokg
Osnabrück, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MySQL
Divers
Thread ID:
01198231
Message ID:
01199073
Vues:
22
This message has been marked as a message which has helped to the initial question of the thread.
>Hello Cetin
>Thank you!
>
>*this works
>select mycursor
>copy to (l_speicherort) TYPE xl5
>LOCAL oExcel AS Excel.Application
>oExcel = CREATEOBJECT([Excel.Application])
>oWorkbook = oExcel.Workbooks.Open(l_speicherort)
>With oExcel.ActiveWorkbook.ActiveSheet
> .UsedRange.Locked = .F.
> .Range('A:E').Locked = .T.
> .Protect('mypassword')
>Endwith
>=oworkbook.save()
>=oExcel.Quit
>
>Is there a way to force some "formats" into the unprotected column F ?
>I need something like min - max (between)
>The excell useres have to enter a rating between 1 and 6 for each row in column F
>
>Any help welcomed
>Thank you again
>Albert

This is slightly modified version of the sample supplied in Validation syntax:
SELECT line_no,order_id,product_id,unit_price,quantity, 0 as myQuantity ;
  FROM (_samples+'data\orditems') ;
  INTO CURSOR crsSample
lcXLS = Sys(5)+Curdir()+'myorders.xls'
Copy To (lcXLS) Type Xls

*** Constant Group: XlDVType
#define xlValidateInputOnly                               0
#define xlValidateWholeNumber                             1
#define xlValidateDecimal                                 2
#define xlValidateList                                    3
#define xlValidateDate                                    4
#define xlValidateTime                                    5
#define xlValidateTextLength                              6
#define xlValidateCustom                                  7
*** Constant Group: XlDVAlertStyle
#define xlValidAlertStop                                  1
#define xlValidAlertWarning                               2
#define xlValidAlertInformation                           3
*** Constant Group: XlFormatConditionOperator
#define xlBetween                                         1
#define xlNotBetween                                      2
#define xlEqual                                           3
#define xlNotEqual                                        4
#define xlGreater                                         5
#define xlLess                                            6
#define xlGreaterEqual                                    7
#define xlLessEqual                                       8

oExcel = Createobject('Excel.application')
With oExcel
  .Workbooks.Open(m.lcXLS)
  .Visible = .T.
  With .ActiveWorkbook.ActiveSheet
    .UsedRange.Columns.Autofit
    * if would apply to whole column
    *   With .Range('F:F').Validation
    With .UsedRange.Columns(6).Validation
      .Add(xlValidateWholeNumber, xlValidAlertStop, xlBetween ,0,6)
      .InputTitle = "Integers 0-6"
      .ErrorTitle = "Integers 0 to 6"
      .InputMessage = "Enter 0 - 6"
      .ErrorMessage = "You must enter a number from 0 to 6"
    ENDWITH
    .Range('F1').Validation.Delete() && remove validation from header
    .UsedRange.Locked = .F.
    .Range('A:D').Locked = .T.
    .Protect('mypassword')
  Endwith
ENDWITH
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform