Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » vbs, odbc, excel, spreadsheet is full
Closed Thread
Old 09-26-2005, 12:39 PM   #1 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,741

office politics will become famous soon enoughoffice politics will become famous soon enough

Default vbs, odbc, excel, spreadsheet is full

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
PHP Code:
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<>0Then
   MsgBox 
"Error Connecting To the Driver""Connection Error"
   
MsgBox err.desc"Description"
   
msgbox "end"
   
OpenConnection ' Return Connection to DB unsuccessful'
   
exit function
  
End IF
  
OpenConnection ' Return Connection to DB successful'
end function ' End OpenConnection' 
I get an error on the following code.

PHP Code:
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.

Last edited by office politics; 02-01-2009 at 03:06 PM.
office politics is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On