环境:win 7+visual basic 2008     侧重:VSTO     界面:sheetbook工作簿

1.创建一个过程并调用(2017.6.3)

Public Class Sheet1
Private Sub Fileprocessor(ByVal fileName As String)
Dim fs As System.IO.FileStream = New System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)
fs.Close()
End Sub Private Sub Sheet1_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Fileprocessor("c:\download\csvdata.txt")
End Sub Private Sub Sheet1_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown End Sub End Class

2.读取TXT文件并显示在sheet1的单元格中(2017.6.3)

Public Class Sheet1

    Private Sub Sheet1_Startup1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Application.ScreenUpdating = False
Application.Workbooks.Open("C:\download\csvdata.txt", Delimiter:=",", Editable:=True, AddToMru:=True)
Application.ScreenUpdating = True
End Sub
Private Sub sheet1_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown End Sub
End Class

3.读取网络地址中的TXT文件并显示在单元格中(2017.6.3)

Public Class Sheet1

    Private Sub Sheet1_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Me.Application.Workbooks.OpenText("http://Download/CSVData.txt", Excel.XlPlatform.xlMacintosh, )
End Sub
Private Sub sheet1_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown End Sub
End Class

4.加载杂项数据(2017.6.3)

Public Class Sheet1

    Private Sub Sheet1_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
With Me.QueryTables.Add(Connection:="URL;http://edition.cnn.com/travel/", Destination:=Range("a1"))
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh(BackgroundQuery:=False)
.SaveData = False
End With
End Sub
Private Sub sheet1_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown End Sub
End Class

5.加载XML文件数据

Public Class Sheet1

    Private Sub Sheet1_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Me.Application.Workbooks.OpenXML("C:\Download\Test.xml")
End Sub
Private Sub sheet1_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown End Sub
End Class

6.Outlook发送的人数超过25个时,以对话框的形式提示。

Imports Outlook = Microsoft.Office.Interop.Outlook
Public Class ThisAddIn Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup End Sub Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown End Sub Private Sub Application_ItemSend(ByVal Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend
Dim myItem As Outlook.MailItem
If TypeOf Item Is Outlook.MailItem Then
myItem = CType(Item, Outlook.MailItem)
For Each recip As Outlook.Recipient In myItem.Recipients
If recip.AddressEntry.Members.Count > Then
'询问用户是否真的要发送这个E-mail
Dim message As String
message = "send mail to {0} with {1} people?"
Dim caption As String = "More than 25 recipients"
Dim buttons As MsgBoxStyle
buttons = MsgBoxStyle.YesNo
Dim result As MsgBoxResult
result = MsgBox(String.Format(message, recip.AddressEntry.Name, recip.AddressEntry.Members.Count), caption, buttons)
If result = MsgBoxResult.Ok Then
Cancel = True
Exit For
End If
End If
Next
End If
End Sub
End Class

最新文章

  1. 微信JSApi支付~坑和如何填坑
  2. C#遍历得到checkboxlist选中值和设置选中项
  3. UIButton的titleEdgeInsets属性和imageEdgeInsets属性实现图片文字按要求排列
  4. LLC 逻辑链路控制
  5. ha456.jar打开dump文件报Unsupported major.minor version 51.0异常
  6. WebService之Axis2(5):会话(Session)管理
  7. HDU 2066 一个人的旅行(单源最短路SPFA)
  8. RedMine项目管理系统邮件推送设置(Windows环境)
  9. rust haskell
  10. 深入理解Tomcat系列之一:系统架构(转)
  11. GUID的获取
  12. pixi.js
  13. OC学习16——对象归档
  14. canvas API总结
  15. c++编码及读写文件
  16. MySQL-压缩版-windows安装
  17. 分类统计的controller和service
  18. How HashMap works in java 2
  19. 熟悉LINUX系统
  20. 第十周PSP&进度条

热门文章

  1. 动态规划-击爆气球 Burst Balloons
  2. python中configparser模块的使用
  3. 雷林鹏分享:查看 XML 文件
  4. spring ----> ResourceBundle [message] not found for MessageSource: Can't find bundle for base name message, local_zh
  5. English trip V1 - B 20. Likes and Dislikes 喜欢和不喜欢 Teacher:Sole Key:
  6. LeetCode--458--可怜的小猪
  7. Jquery常用的一些事件 keyup focus
  8. php文件处理函数
  9. Git将本地项目上传到GitHub
  10. 转-如何使用iTunes制作iPhone铃声