i have built macro building , running sql queries. pretty happy far. thing add ability in windows double click .sql file , opens inside macro. sample below:

this code opens sql file when load query pressed.
sub loadquery() dim fnameandpath variant fnameandpath = application.getopenfilename(filefilter:="sql query files (*.sql), *.sql", title:="select file opened") if fnameandpath = false exit sub open fnameandpath input #1 sheets("sheet1").sql_query = input$(lof(1), 1) close #1 sheets("sheet1").sqlfilename.caption = fnameandpath end sub is possible? don't think thought check guys first.
what have tried far? nothing, because don't know start, uncle google didn't hook brother in fact confused me more.
using ideas below went this:
option explicit dim xlapp, xlbook, fnameandpath set xlapp = createobject("excel.application") set xlbook = xlapp.workbooks.open("g:\analytics reporting archive\sql client.xlsm", 0, true) xlapp.open wscript.arguments(0) input #1 xlbook.sheets("sheet1").sql_query = input$(lof(1), 1) xlapp.close #1 xlbook.sheets("sheet1").sqlfilename.caption = fnameandpath set xlbook = nothing set xlapp = nothing wscript.quit this didn't work, didn't opening text file (sql file) went creating small routine in excel app:
sub loadquerydblclick(queryfilename string) open queryfilename input #1 sheets("sheet1").sql_query = input$(lof(1), 1) close #1 sheets("sheet1").sqlfilename.caption = fnameandpath end sub this called in vbs so:
option explicit dim xlapp, xlbook, fnameandpath set xlapp = createobject("excel.application") set xlbook = xlapp.workbooks.open("g:\analytics reporting archive\sql client.xlsm", 0, true) xlapp.run "loadquerydblclick " & wscript.arguments(0) set xlbook = nothing set xlapp = nothing wscript.quit brilliant right?
no :(. "would" work, of confident (and extremely grateful guys posted replies me got me far) alas citrix strikes again:
error: activex component can't create object: 'excel.application'
i confident guys have solved in citrix issue.
see here how create custom extension , associate action.
what might work in case associate extension vbs file takes launching sql filepath parameter , opens excel file using automation, loads sql file workbook.
Comments
Post a Comment