以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助] excel文件关闭 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=187810) |
-- 作者:sanny -- 发布时间:2023/8/13 14:50:00 -- [求助] excel文件关闭 老师,使用以下代码执行后,再去打开这个data 文件,显示这文件还在使用中,实际没有excel文件处理打开中,如何真正关闭这个Data文件 ? Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("C:\\Users\\wj1087\\Desktop\\改善项目\\Project\\Data\\Data.xlsx") Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(2)\'指定工作表 Dim range = ws.range("B1:I22") range.CopyPicture(Appearance:=1, Format:=2) ClipBoard.GetImage.save("C:\\Users\\wj1087\\Desktop\\改善项目\\Project\\Data\\Data1.jpg") Dim o As New Microsoft.Office.Interop.Outlook.Application Dim msg As Microsoft.Office.Interop.Outlook.MailItem Dim m As New MailSender Dim ln As String = vbcrlf & vbcrlf Dim dr As DataRow msg = o.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem) msg.Subject = "Sales Order & Production order Overview" msg.Attachments.Add("C:\\Users\\wj1087\\Desktop\\改善项目\\Project\\Data\\Data.xlsx") Dim body As String = "<html><body>内容</body></html>" Dim bmp As new Bitmap("C:\\Users\\wj1087\\Desktop\\改善项目\\Project\\Data\\Data1.jpg") \'图片路径 Dim ms As new System.Io.MemoryStream() bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg) Dim arr(ms.Length) As Byte ms.Position = 0 ms.Read(arr, 0, ms.Length) ms.Close() Dim strbase64 As String = Convert.ToBase64String(arr) bmp.dispose Dim content As String ="<img style = ""height:20px"" src=""data:image/jpeg;base64," & strbase64 & """ > " msg.HTMLBody = body.Replace("内容", " "& content) msg.Recipients.Add("summer@bxiexe.com") msg.Send() msgbox("Done") [此贴子已经被作者于2023/8/13 18:20:44编辑过]
|
-- 作者:有点蓝 -- 发布时间:2023/8/13 19:57:00 -- App.quit |