Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop msg's after closing excel

Status
Not open for further replies.

vbmorton

Technical User
Dec 27, 2004
44
US
Was wondering if anyone can point me in the right direction, using VB6 to open and close a spreadsheet in excel, after the close of the spread sheet a msg pops up.. "Do you want to update file.exl" is there a way to auto reply to this msg or for this msg not to come up???



Thanks

VBMORTON
 
are you changing the exl template file? How are you opening and closing Excel and why?

Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
Here is what i have so far.


' Create an instance of Excel
Set g_objExcelApp = New Excel.Application

' Open Selected Excel file
g_objExcelApp.Workbooks.Open (g_strFilePath & "\" & g_strFileName)
Set g_xlsWS = g_objExcelApp.Sheets(1)

' Update Excel spreadsheet
With g_xlsWS
.Range("D" + Trim(m_strCellCnt)).Value = m_strErrorMessage
End With

' Close Spreadsheet
g_objExcelApp.Workbooks.Close
g_objExcelApp.Quit
Set g_xlsWB = Nothing
Set g_xlsWS = Nothing
Set g_objExcelApp = Nothing
 
I don't see anywhere you to save the changes. If i remember well .Save() or .SaveAs() methods.
To be sure you can set (if i remember again well) the Excel's application property .DisplayAlerts=False.

 
Try this...

With g_xlsWS
.Range("D" + Trim(m_strCellCnt)).Value = m_strErrorMessage
.SaveAs (g_strFilePath & "\" & g_strFileName)
End With


If not then This

g_objExcelApp.Workbooks.Close
g_objExcelApp.SaveWorkspace(g_strFilePath & "\" & g_strFileName)
g_objExcelApp.Quit


Casper

There is room for all of gods creatures, "Right Beside the Mashed Potatoes".
 
When you close excel, close the worksheet first since when you close the worksheet you get an argument for saving it as in g_objExcelApp.Workbooks(1).Close False. This way, whatever changes you made will not be saved and you won't be asked to save them.
-Max
 
This will work:

' Close Spreadsheet
g_objExcelApp.ActiveWorkbook.Save
g_objExcelApp.Workbooks.Close
g_objExcelApp.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top