Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Format Excel sheet

Hi

I have a excel spread sheet that has data in it. I have created a VB app that formats column A so if the value of the cell is less than one then the colour of the font is red:

Private Sub Form_Load()
Dim AppExcel As New Excel.Application

Set AppExcel = CreateObject("Excel.Application")

Dim wSheet As Worksheet
Dim wBook As Workbook

Set wBook = AppExcel.Workbooks.Open("c:\result.xls")
Set wSheet = AppExcel.Sheets(1)

Columns("A:A").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:="1"
Selection.FormatConditions(1).Font.ColorIndex = 3

wBook.save

AppExcel.Quit

Set AppExcel = Nothing
Set wBook = Nothing
Set wSheet = Nothing

End
End Sub

The problem is when I save (wbook.save) a pop up box appears asking if you want to replace the one thats there ?? Can I stop this ?? why is it doing this I am only doing a save not a save as right ?? also on the "End" VB does not seem to close down the Excel process and this is left running if you look in task manager.

If you try to open the spread sheet it says some one has it open do you want to open it in read only. If I kill the excel process that is running this does not happen. Again can I stop this happening ??

Please help as this is doing my head in now
[1462 byte] By [ascona] at [2007-11-11 10:30:43]