zoukankan      html  css  js  c++  java
  • VSTO杂项拾零(持续更新中……)

       环境: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:downloadcsvdata.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:downloadcsvdata.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, 3)
        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:DownloadTest.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 > 25 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
  • 相关阅读:
    MySQL循环插入语法
    查看linux机子的配置
    extends与implements的不区别
    Git基本命令
    VirtualBox配置 以及文件传输
    zookeeper应用场景
    oracle学习
    linux学习
    Mysql优化
    线程3
  • 原文地址:https://www.cnblogs.com/xiehaofeng/p/6936706.html
Copyright © 2011-2022 走看看