以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]如何定位到文件? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=179964) |
-- 作者:hzcaqjf -- 发布时间:2022/9/20 20:54:00 -- [求助]如何定位到文件? 下面代码只是定位到刚保存文件所在的目录,如何定位到刚保存的文件(使之处于选定状态而不打开)? Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter = "Excel文件|*.xls" \'设置筛选器 dlg.FileName = "订单" If dlg.ShowDialog = DialogResult.Ok Then Dim Book As New XLS.Book Book.DefaultFont = New Font("宋体", 10) Dim Sheet As XLS.Sheet = Book.Sheets(0) Sheet.Name = "单位1" Book.Save(dlg.FileName) Dim Proc As New Process Proc.File = dlg.FileName.Substring(0, dlg.FileName.LastIndexOf("\\")) Proc.Start() End If |
-- 作者:有点蓝 -- 发布时间:2022/9/20 21:32:00 -- http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=148600&skin=0 |
-- 作者:hzcaqjf -- 发布时间:2022/9/21 9:11:00 -- 好了,要的就是这个效果: Dim dlg As New SaveFileDialog \'定义一个新的SaveFileDialog dlg.Filter = "Excel文件|*.xls" \'设置筛选器 dlg.FileName = "订单" If dlg.ShowDialog = DialogResult.Ok Then Dim Book As New XLS.Book Book.DefaultFont = New Font("宋体", 10) Dim Sheet As XLS.Sheet = Book.Sheets(0) Sheet.Name = "单位1" Book.Save(dlg.FileName) Dim Proc As New Process Proc.File = "explorer.exe" \'指定要执行的文件 Proc.Arguments = " /select," & dlg.FileName & " " \'指定命令行参数 Proc.Start() End If 感谢蓝老师和y2287958的帮助. |