Linker IT Software
Google
Web www.oraxcel.com
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
Macro to execute insert statement (Read 3383 times)
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 75
Macro to execute insert statement
09.12.05 at 11:38:38
 
Lloyd from the USA asked the following question today:
 
Question:
I have a macro that makes a SQL insert statement. How do I use SQL*XL to run it?
 
Answer:
The easiest way to make a macro for it it is to use the macro recorder in Excel. Start the macro recorder and execute an insert command from the SQL dialog. Stop the macro recorder and inspect the code. It will look like this:
Code:
Sub Macro1()
  SQLXL.Sql.setText <<the sql statement in double quotes>>
End Sub
 


Sorry but this board does not seem to be able to take double quotes today...
 
You can easilly change this code to include your SQL insert statement. E.g.
Code:
Sub Macro2()
  Dim strSQL As String

  strSQL = <<your SQL string here>>  
  SQLXL.Sql.setText strSQL
  SQLXL.Sql.Statements(1).Execute
End Sub
 

Back to top
 
« Last Edit: 09.12.05 at 11:42:55 by Gerrit-Jan Linker »  

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Pages: 1