Writing Data to Excel from VB6 
Author Message
 Writing Data to Excel from VB6

Hi I have some text code below which runs on clicking a
button on a form in VB6.

However, the user is prompted to save the file on the
interface.

I want to save the file and have no save message
displayed. How do I do this?

#############################

Dim xlsApp As excel.Application          
Set xlsApp = excel.Application

With xlsApp
   '.Visible = True
   .Workbooks.Open ("C:\Test.xls")
   .Range("A1").Value = "Cell1"
   .Range("B1").Value = "Cell2"

End With

xlsApp.Workbooks.Close
xlsApp.Quit
######################



Fri, 02 Dec 2005 19:44:40 GMT  
 Writing Data to Excel from VB6
Hi CG,

Add the DisplayAlerts before the close statement:

    xlsApp.DisplayAlerts = False
    xlsApp.Workbooks.Close
    xlsApp.Quit

Written this way the Close method defaults to not saving the workbook.  Add
True after the close if you want to save it.

HTH,

Simon


Quote:
> Hi I have some text code below which runs on clicking a
> button on a form in VB6.

> However, the user is prompted to save the file on the
> interface.

> I want to save the file and have no save message
> displayed. How do I do this?

> #############################

> Dim xlsApp As excel.Application
> Set xlsApp = excel.Application

> With xlsApp
>    '.Visible = True
>    .Workbooks.Open ("C:\Test.xls")
>    .Range("A1").Value = "Cell1"
>    .Range("B1").Value = "Cell2"

> End With

> xlsApp.Workbooks.Close
> xlsApp.Quit
> ######################



Fri, 02 Dec 2005 20:34:19 GMT  
 Writing Data to Excel from VB6
You can set the DisplayAlerts property of the Excel application to False.  This
will disable the Save As dialog generated by Excel.  However, make sure you
enable it before you unload your app.

Ryan Block



Fri, 02 Dec 2005 20:39:48 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Writing data to Excel from VB6

2. Writing recordsets to an excel file (VB6)

3. Writing recordsets to an excel file using VB6

4. VB6 project reading/writing Excel spreadsheet

5. VB6: Accessing/Writing to Excel files

6. Write data from excel to MS-Access using VBA

7. Writing data into particular cell in Excel

8. how to write a VB to import and export data to/from SQL2K to Excel

9. how write a vb to import from and export data to excel fromm SQL sever

10. how write a vb to import from and export data to excel fromm SQL sever

11. how to write a VB to import and export data to/from SQL2K to Excel

12. Write Data from VB6-DB-Application into Word-Document

 

 
Powered by phpBB® Forum Software