Cant Overwrite My Excel File Which Is My Datasource フォローする

Legacy Poster

Hi guys, i am using bartender 10.1. What I am trying to do is, every time i want to print my label, bartender will grab the serial number from my excel file [Microsoft Excel 97-2003 Worksheet (.xls)] and after each print, bartender will serialize and update my excel file, eg. 0001 and next print, the serial number will be 0002. I sourced this forum and i saw people posted this method and i improvise to suit me: 


'NewRecord event
dim objConn
dim strConn
dim rs
'Define the database connection parameter constants.
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Users\a\S.xls';Extended Properties=""Excel 8.0;HDR=YES;"""
Set rs = CreateObject("ADODB.Recordset") "SELECT * FROM [Sheet1$]", objConn, adOpenStatic, adLockOptimistic, adCmdText
rs.Find "Serialnum = '" & Field("Sheet1$.Serialnum") & "'"
rs.Fields("Printed") = "YES"



However, i got this error, "BarTender Error Message 6900. The following script error was found. cannot update. Database or object is read only. I checked my excel file properties, security and I checked that all the adminstrator, User, System has the permission to read or write. May i know what could the problem be? 



The reason i didnt use global data field for serialization because I will want the bartender to have the power to print back serial number that i printed before. But right now, I only wish i can overwrite my excel file. Any help will be appreciated! thank you.