Creating a new EXCEL file フォローする

Paweł Gancarz

I wanted to ask someone for help.
I want to create a script that will ask me via the input form when printing if I want to create a new document (.xls file) with the name specified by the user.
I give it a name and it saves it in the same folder where the .BTW file is located
Additionally, it will replace the name in my script, so that I can save the data during printing.

'Place script below at to
If Format.IsPrinting = False then Exit sub

Dim objCon
Dim strSQL

Set objCon = CreateObject("ADODB.Connection")
'Create connection (in the case of xls file in the same folder as btw file)
objCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='XXXX.xls';Extended Properties=""Excel 8.0;HDR=YES;"""

'Create statement
strSQL = "INSERT INTO [Arkusz1$] (IL,RL,ZK) values ('" & A1 & A2 & A3 &"','" & B1 & B2 & B3 &"','" & zk &"')"


'Run SQL
objCon.Execute strSQL

'Close connection
Set objCon = Nothing

Thank you for your help.