Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Yousfi Benameur
  Where is Yousfi Benameur?
 El Bayadh
 Yousfi Benameur
 To: Kavita Jaiswal
  Where is Kavita Jaiswal?
 Kavita Jaiswal
Subject: RE: Excel Automation
Thread ID: 189261 Message ID: 189425 # Views: 5 # Ratings: 0
Version: Visual FoxPro 9 Category: Microsoft Office Automation
Date: Thursday, August 14, 2008 10:02:00 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

Hi Kavita
This is my code to save an excel file to any fileformat recognized by excel automatically.
There is around 40 fileformats.
Open the excel file you want and choice the fileformat.Execute this PRG.
*Yousfi Benameur 14 Aout 2008
*saving an excel file as any fileformat authorised.

*terminate any instance of excel (particulary in windows task manager is there instances not killed)-Jump this etap is not needed.
LOCAL loWMI, lcQuery, loResult, loProcess
loWMI = GetObject("winmgmts://")
lcQuery = "select * from win32_process where name='excel.exe'"
loResult = loWMI.ExecQuery(m.lcQuery)
FOR EACH loProcess IN loResult

&&save an excel file as any fileformat authorised.
*** all Excel Constant : xlFileFormat
#define xlAddIn                                           18
#define xlCSV                                             6
#define xlCSVMac                                          22
#define xlCSVMSDOS                                        24
#define xlCSVWindows                                      23
#define xlDBF2                                            7
#define xlDBF3                                            8
#define xlDBF4                                            11
#define xlDIF                                             9
#define xlExcel2                                          16
#define xlExcel2FarEast                                   27
#define xlExcel3                                          29
#define xlExcel4                                          33
#define xlExcel5                                          39
#define xlExcel7                                          39
#define xlExcel9795                                       43
#define xlExcel4Workbook                                  35
#define xlIntlAddIn                                       26
#define xlIntlMacro                                       25
#define xlWorkbookNormal                                  -4143
#define xlSYLK                                            2
#define xlTemplate                                        17
#define xlCurrentPlatformText                             -4158
#define xlTextMac                                         19
#define xlTextMSDOS                                       21
#define xlTextPrinter                                     36
#define xlTextWindows                                     20
#define xlWJ2WD1                                          14
#define xlWK1                                             5
#define xlWK1ALL                                          31
#define xlWK1FMT                                          30
#define xlWK3                                             15
#define xlWK4                                             38
#define xlWK3FM3                                          32
#define xlWKS                                             4
#define xlWorks2FarEast                                   28
#define xlWQ1                                             34
#define xlWJ3                                             40
#define xlWJ3FJ3                                          41
#define xlUnicodeText                                     42
#define xlHtml                                            44
xfileformat=xlHtml    &&Choice a fileformat see constants above
if empty(lcFile)

function ysaveExcel()
lparameters lcfile,xfileformat
oExcel = createobject('Excel.Application')
oExcel.DisplayAlerts = .F.
messagebox("Your Excel file "+lcFile +" saved to fileformat "+trans(xfileformat),0+32+4096)

Yousfi Benameur


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