excel,vba,sql,txt

A

atidelphi

Hi all, im a very beginner wiv Excel and VB. Im trying to create a tex
file from excel table, every excel worksheet row will be a sq
sentence. like this;

row1 has cells (a1,b1,c1,d1,e1,f1)
row2 has cells (a2,b2,c2,d2,e2,f2)
Im trying to write these cells into a text file just like this;

insert into mytable (id,name,surname,fax,tel,mail) values (<!-- her
ill put cell values --> a1,b1,c2...)
insert into mytable (id,name,surname,fax,tel,mail) values (<!-- her
ill put cell values --> a1,b1,c2...)
My problems :
1 - how a loop system ill put that is not dependent to number of row
and cells
2 - how ill put a carriage return to text file after every sql sentenc
for to begin from a new line

Here my tryings.................

Sub sqlyap()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\insertsql.txt", True)
'Do
'rows.cellvalues=??????????????????
cumle = "INSERT INTO MYTABLE (id,name,surname,fax,tel,mail) VALUES ("
cellvalues + ");\r\n"

a.WriteLine (cumle)
'loop
a.Close
End Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top