读取Excel表的最后一行和最后一列的代码是什么?

发布于 2025-01-24 23:49:08 字数 1038 浏览 4 评论 0原文

早上好,

我在下面有此代码,该代码在电子邮件的正文中发送带有附件(Excel文件)的电子邮件(Excel文件)和表格。

Sub Email()

Dim outapplication As Object
Dim nEmail As Object
Set outapplication = CreateObject("outlook.application")
Set nEmail = outapplication.CreateItem(olMailItem)
strTime = Date

With nEmail
.Display
.To = "[email protected]"
.CC = ""
.Subject = "Email's title" & " " & strTime
.attachaments.Add "G:\path\test.XLSX"


With .GetInspector.WordEditor.Windows(1).Selection
.typetext "E-mail's body"
.typeParagraph
.typeParagraph
.typetext "Following the table:"
.typeParagraph
.typeParagraph
.typeParagraph
Sheets("TOP").Select
ActiveSheet.Range("a1:B21").Copy 'Here to change the code
.Paste
.typeParagraph
.typeParagraph
Application.CutCopyMode = False
End With
   
.Send

End With

Set outapplication = Nothing
Set nEmail = Nothing



End Sub

- 我想选择一个特定的表(因为它是从“ A1:B21”中),我希望代码检查表的最后一列和最后一行。

Good morning,

I have this code below that send an email with an attachement (excel file) and a table in email's body.

Sub Email()

Dim outapplication As Object
Dim nEmail As Object
Set outapplication = CreateObject("outlook.application")
Set nEmail = outapplication.CreateItem(olMailItem)
strTime = Date

With nEmail
.Display
.To = "[email protected]"
.CC = ""
.Subject = "Email's title" & " " & strTime
.attachaments.Add "G:\path\test.XLSX"


With .GetInspector.WordEditor.Windows(1).Selection
.typetext "E-mail's body"
.typeParagraph
.typeParagraph
.typetext "Following the table:"
.typeParagraph
.typeParagraph
.typeParagraph
Sheets("TOP").Select
ActiveSheet.Range("a1:B21").Copy 'Here to change the code
.Paste
.typeParagraph
.typeParagraph
Application.CutCopyMode = False
End With
   
.Send

End With

Set outapplication = Nothing
Set nEmail = Nothing



End Sub

-I would like to instead of selecting a specific table (as it is from "a1:b21"), I would like the code to check the last column and the last row of the table.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文