Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi !

 

I have a form1 and when i press on button1 i want to open an existing Excel file, i write in it, i print it and then close it without saving changes.

 

'Opening the existing file

Dim xlApp As Excel.Application

Dim xlbook As Excel.Workbook

Dim xlsheet As Excel.Worksheet

xlApp = New Excel.Application

xlbook = xlApp.Workbooks.Open(C:\Model.xls")

xlsheet = xlApp.Sheets(1)

xlsheet.Name = "Hello"

 

'(Then comes all the writing in the sheet)

 

'Printing without saving

xlsheet.PrintOut()

xlApp.Quit()

xlsheet = Nothing

xlbook = Nothing

xlApp = Nothing

 

Now the problem is that when i execute the program, VB opens the files, writes an prints but when it closes the file i get the usual message from Excel asking me if i want to save the changes in the initial file.

I don't want this message to appear, i want VB to automatically say "No" to it...

 

How do i do that?

 

Help is needed urgently... :eek: Thank you!!!!!

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...