vba - change cell properties from an excel file open with a wsf script -


i have wsf script, vritten in visual basic, run db2 query , save results in file .csv .

function creacsvdasql (sql,filecompletepath)    dim input , conn,rs,csvtext,fso,fs,line   set conn = createobject ("adodb.connection")    conn.open _    "provider=sqloledb.1;initial catalog=xxxx;data source=xxxxx;mars connection=true;user id=xxxx;password=xxxx"    set rs = conn.execute (sql)    line = ""   dim tmp   each tmp in rs.fields       line=line & tmp.name & ";"   next    if (not rs.eof)        csvtext = line & vbcrlf & rs.getstring (2,, ";", vbcrlf)        rs.close: set rs = nothing        conn.close: set conn = nothing         dim l_sn        l_sn = replace (now, "-", "")        l_sn = replace (l_sn, ":", "")        l_sn = replace (l_sn, "", "")         set fso = createobject ("scripting.filesystemobject")        set fs = fso.createtextfile (filecompletepath, true)        fs.writeline (csvtext)        fs.close: set fs = nothing        set fso = nothing     end if  end function 

everytime collegue open file csv excel have change cell in text format, try find way programmatically, without macro, because file deleted everytime script run , cannot store macro.

somebody can me ? thanks.

a .csv file can't store data type/meta info columns. if db2 not provide tools export .xls directly/reliably, options are:

  1. create schema.ini file describe structure of .csv
  2. use import dialog wizard create , save suitable import specification; open .csv via macro refering specs
  3. enhance sql query concatenating quotes or re-formatting appropriate
  4. open .cvs using "excel.application", necessary changes, save .xls

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -