office politics
It's all just 1s and 0s
- Messages
- 6,555
- Location
- in the lab
im trying to add records to an excel file using a vbscript. I'm connecting to the excel file through an ADODB connection.
I use this code to connect
I get an error on the following code.
When i execute my script, i get the following error.
attached is a copy of the full script and excel file in a zip file.
I use this code to connect
PHP:
function OpenConnection
'Set Up Connection Object'
Set ExcelConnect = CreateObject("ADODB.Connection")
'Open Connection'
ExcelConnect.Open "Driver={Microsoft Excel Driver (*.xls)};" & _
"DriverId=790;" & _
"Dbq=" & RouteName & ";" & _
"DefaultDir=" & RoutePath & ";" & _
"ReadOnly=0;"
'Check Connection'
If (Err.Number<>0) Then
MsgBox "Error Connecting To the Driver", 0 , "Connection Error"
MsgBox err.desc, 0 , "Description"
msgbox "end"
OpenConnection = 0 ' Return Connection to DB unsuccessful'
exit function
End IF
OpenConnection = 1 ' Return Connection to DB successful'
end function ' End OpenConnection'
I get an error on the following code.
PHP:
sub AddUWs
for i=0 to ubound(clob) 'Add Commerical UWs'
strquery = "INSERT INTO MYTABLE (AGENT, ENDT) VALUES ('" & AgentCode & clob(i) & "','" & CUW & "')"
ExcelConnect.execute(strQuery) 'Run Query'
Next
for i=0 to ubound(plob) 'Add Personal UWs'
strquery = "INSERT INTO MYTABLE (AGENT, ENDT) VALUES ('" & AgentCode & plob(i) & "','" & PUW & "')"
ExcelConnect.execute(strQuery) 'Run Query'
Next
end sub 'End Add UWs'
When i execute my script, i get the following error.
attached is a copy of the full script and excel file in a zip file.