Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: Kavita Jaiswal
  Where is Kavita Jaiswal?
 Calcutta
 India
 Kavita Jaiswal
 Tags
Subject: RE: Excel Automation
Thread ID: 189261 Message ID: 189337 # Views: 4 # Ratings: 0
Version: Visual FoxPro 9 Category: Microsoft Office Automation
Date: Thursday, August 14, 2008 1:07:38 PM         
   


> Hi all,
>
> Can anyone help me out that how can I always close an Excel Sheet promting "Save as" instead of "Save" dialog box ,as I don't want the user to use the Template Excel Sheet.
>
> Beside the above problem how can i protect a given cell range, instead the entire sheet in an Excel sheet.
>
>
> Cheers
> Kavita

You don't need "save as" for that, use templates (you are saying that you use a template but looks like you're using the same workbook and saving as a different file instead). With a template:

lcTemplateName = 'c:\myFolder\myTemplate.xlt'
lcXLSName = 'c:\myFolder\myFile.xls'
oExcel = createobject('Excel.Application')
oExcel.Workbooks.Add(m.lcTemplateName)
oExcel.ActiveWorkbook.SaveAs(m.lcXLSName)
* ...


Templates are not overwritten.

For your second question, in this sample all but the last column is protected:

Use (_samples+'data\orders')
lcXLS = fullpath('orders.xls')
Copy To (m.lcXLS) Type Xls
lcLastColumn = Chr(Asc('A')-1+Fcount()) && Last col not locked

oExcel = Createobject('Excel.application')
With oExcel
  .Workbooks.Open(lcXLS)
  With .ActiveWorkbook.ActiveSheet
    .UsedRange.Locked = .T.
    .Range(m.lcLastColumn+':'+m.lcLastColumn).Locked = .F. && Unprotect last column
    .Protect('mypassword')
  Endwith
  .Visible = .T.
Endwith


Cetin Basoz

ENTIRE THREAD

Excel Automation Posted by KAVITA JAISWAL @ 8/14/2008 7:17:46 AM
RE: Excel Automation Posted by surinder singh @ 8/14/2008 7:42:21 AM
RE: Excel Automation Posted by Cetin Basoz @ 8/14/2008 1:07:38 PM
RE: Excel Automation Posted by Yousfi Benameur @ 8/14/2008 10:02:00 PM