Hi,
Regarding MsgBox: MsgBox displays a message on the screen; however, the code is on the server, so the message box would show on the server, which is ignored by it so that the it wouldn't be locked down until a user sat down in front of the server and clicked "OK" on the message box.
I would say a better approach would be to make an OleDb connection to the Excel file, from which you can insert sheets, etc. if the Excel file exists.
Use your code for checking if a file exists; if the file exists, connect to the file using an OleDb connection (reference www.connectionStrings.com for help with constructing an appropriate connection string). Here is example code I wrote which worked, adding a sheet named "test" to the file, test.xsl:
Dim strExcelFile As String = Server.MapPath("~/test.xls")
Dim strExcelFolder As String = strExcelFile.Substring(0, strExcelFile.LastIndexOf("\"))
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + strExcelFile + ";Extended Properties=Excel 8.0"
Dim con As New OleDbConnection(connectionString)
con.Open()
Dim com As New OleDbCommand("CREATE TABLE [test] ( A INT, B INT )", con)
com.ExecuteNonQuery()
con.Close()
Also, make sure that the Excel file is not Read-Only, and that the IUSR_ user has read/write access to the file.
~ mellamokb