W
Winshent
I need to write to a protected excel worksheet. So far i have code which can
write to an unprotected sheet as below:
Help would be much appreciated
++++++++++++++++++++++++++++++++++++++++++++++
Private Sub WriteIDtoXL(ByVal str)
Dim conn1 As New System.Data.OleDb.OleDbConnection(xlConn(str))
conn1.Open()
Dim cmd As New System.Data.OleDb.OleDbCommand
cmd.Connection = conn1
cmd.CommandText = "INSERT INTO [CCID] (ID) values (" &
Session("mCallCentreID") & ")"
cmd.ExecuteNonQuery()
conn1.Close()
End Sub
Private Function xlConn(ByVal FilePath As String) As String
xlConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
FilePath & ";Extended Properties=""Excel 8.0;HDR=YES;MAXSCANROWS=4"""
End Function
+++++++++++++++++++++++++++++++++++++++++++++++++++++
write to an unprotected sheet as below:
Help would be much appreciated
++++++++++++++++++++++++++++++++++++++++++++++
Private Sub WriteIDtoXL(ByVal str)
Dim conn1 As New System.Data.OleDb.OleDbConnection(xlConn(str))
conn1.Open()
Dim cmd As New System.Data.OleDb.OleDbCommand
cmd.Connection = conn1
cmd.CommandText = "INSERT INTO [CCID] (ID) values (" &
Session("mCallCentreID") & ")"
cmd.ExecuteNonQuery()
conn1.Close()
End Sub
Private Function xlConn(ByVal FilePath As String) As String
xlConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
FilePath & ";Extended Properties=""Excel 8.0;HDR=YES;MAXSCANROWS=4"""
End Function
+++++++++++++++++++++++++++++++++++++++++++++++++++++