| 发表于:2007-05-20 16:38:09 楼主 |
原本我的程序是通过在程序中指定路径打开特定的文件直接操作的 现在想加添加一个open钮并在textbox中显示打开的文件名 再按执行键对所打开的文件进行操作 现在我把两个程序分别贴出来 请大大们帮我进行连接 执行单一路径指定文件 private sub command1_click() dim xlapp as new excel.application dim xlbook as excel.workbook dim xlsheet as excel.worksheet dim lsfilename as string dim llrow as long dim llcol as long dim lstemp as string dim n() as string lsfilename = app.path & "\sjdm " llrow = 0 set xlbook = xlapp.workbooks.add() set xlsheet = xlbook.worksheets(1) open lsfilename & ".dat " for input as #1 do while not eof(1) line input #1, lstemp n = split(lstemp, chr(9)) debug.print lstemp llrow = llrow + 1 for llcol = 0 to ubound(n) xlsheet.cells(llrow, llcol + 1) = n(llcol) next loop close #1 xlbook.saveas lsfilename & ".xls " xlbook.close (true) xlapp.quit set xlapp = nothing end sub 文件浏览打开程序: private sub cmdopen_click() on error resume next cdltest.cancelerror = true cdltest.dialogtitle = "打开文件 " cdltest.filename = " " cdltest.filter = "所有文件 (*.*) ¦*.* " cdltest.flags = cdlofncreateprompt + cdlofnhidereadonly cdltest.showopen if err = cdlcancel then exit sub textboxopen.text = cdltest.filename end sub 如果需要源文件我可以发给大大,请亲自指教 |
|
|
|
|