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
  • 相关阅读:
    笔试题 易错题目解析
    SqlServer 函数 大全
    视频上传到自己的服务器打不开
    sql 计算生日提请日期
    Web API 异常处理(转)
    微软源代码管理工具TFS2013安装与使用详细图文教程(Vs2013)
    关于枚举的用法和类型转换
    html title换行方法 如a链接标签内title属性鼠标悬停提示内容换行
    JS的parent、opener、self对象
    uploadfiy
  • 原文地址:https://www.cnblogs.com/xiehaofeng/p/6936706.html
Copyright © 2011-2022 走看看