Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel file doesn't close and exit Excel application
Message
De
22/10/2015 00:29:57
Yim Ming Sun Derek
Spacious Design Consultant
Hong Kong, Hong Kong
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Excel file doesn't close and exit Excel application
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01626305
Message ID:
01626305
Vues:
43
Hi,
I use VFP9 to create a excel file and export some data to the excel file and then
want to Save it, close the worksheet and exit the Excel application.

I find the oWorkbooks.SAVE and oWorkbooks.CLOSE command not work.
also, use what statement to quit the Excel applcation ?

The worksheet and the Excel application still open, when I close the Excel, it ask me to save the
it or not, because the worksheet have modified.

Please advise.
ctargetfile = "c:\client.xls"
EXPORT TO &ctargetfile TYPE XL5 FIELDS cusmas->cusno,cusmas->cusname
TRY
oExcel = CREATEOBJECT([Excel.Application])
oWorkbook = oExcel.Workbooks.open(ctargetfile)
oExcel.Visible = .t.
WITH oExcel.activesheet
          .PageSetup.Orientation = xlLandScape
          .PageSetup.TopMargin =12
          .PageSetup.LeftMargin =20
          .PageSetup.BottomMargin =20
          .PageSetup.RightMargin =15  
          .Range("A1").value = "Client Code"
          .Range("B1").value = "Client Name"
          .Range("1:1").font.bold = .t.   
....
ENDWITH 
oWorkbooks.Save(ctargetfile)
oWorkbooks.Close
CATCH
  MessageBox([There is no EXCEL installed])
ENDTRY
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform