yonggl吧 关注:17贴子:74

VBA编码集合

只看楼主收藏回复

1 读写文件
Open "Test.txt" For output as #1
Write #1, val(cells(2,1))
Close #1


来自Android客户端1楼2016-04-05 11:00回复
    2 . 16进制数转换为10进制数:val("&H"&cells(2,1))


    来自Android客户端2楼2016-04-05 11:01
    收起回复
      补1:参考Get和Put语句


      来自Android客户端3楼2016-04-05 14:00
      回复
        使用正则表达式:1 vba编辑工具->引用 添加Microsoft Vbscript regular express 5.5。2 dim re as new regexp 3 with re
        .global=true
        .ignoreCase=true
        .pattern="[\u4e00-\u9fa5]+"'查找所有中文字符
        End with


        来自Android客户端4楼2016-05-21 09:44
        收起回复
          获取列表编号
          表格中t.cell(1,1).range.listformat.liststring


          来自Android客户端5楼2016-07-23 09:37
          回复
            调整文档标题
            Dim p as paragraph
            For each p in activedocument.paragraphs
            If instr(1,p.style,"标题 6")>0 then p.style=activedocument.styles("标题 5")
            Next


            来自Android客户端6楼2016-07-23 16:53
            回复
              字典的使用
              Dim dict as object
              Set dict=createobject("scripting.dictionary")
              Dict("A")=1
              If Not dict.exist("A") then...


              来自Android客户端7楼2016-07-28 12:09
              收起回复
                替换表格中的回车
                Replace(cell,chr(13),"")


                来自Android客户端8楼2016-09-27 16:53
                收起回复
                  获取类型
                  Function gettype (dict as Object, s as string) as string
                  Gettype=""
                  For each d in dict.keys
                  If instr(s,d)>0 Then
                  Gettype=dict(d)
                  Goto ok
                  Endif
                  Next
                  Ok:
                  End function


                  来自Android客户端9楼2017-02-18 11:10
                  回复
                    使用系统书签快速获取插入点的标题
                    Paragraph.range.Select
                    Selection.bookmarks("\headinglevel").range.listformat.liststring


                    来自Android客户端10楼2017-03-13 15:43
                    回复
                      Selection.information 可获取选定内容的信息,如文档页码信息、是否在表格内等,参考wdinformation


                      来自Android客户端11楼2017-03-14 12:41
                      回复
                        获取mac
                        Dim MyMac
                        Set MyMac = GetObject("Winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
                        For Each MyMacAddress In MyMac
                        If MyMacAddress.IPEnabled = True Then
                        MsgBox "本机网卡MAC地址是:" & MyMacAddress.MacAddress
                        Exit For
                        End If
                        Next


                        来自Android客户端12楼2017-03-23 08:44
                        回复
                          Sub 处理表格和标题()
                          Dim i As Single, tt As String, r As Integer
                          Dim myrange As Range, para As Paragraph, t As Table
                          On Error Resume Next
                          For Each t In ActiveDocument.Tables
                          If InStr(t.Cell(1, 1).Range, "序号") > 0 Then
                          Set para = t.Cell(1, 1).Range.Paragraphs(1).Previous
                          Do While Not (para Is Nothing) 'search title
                          If InStr(para.Style, "标题") > 0 Then
                          tt = para.Range
                          Exit Do
                          Else
                          Set para = para.Previous
                          End If
                          Loop
                          Debug.Print para.Range.ListFormat.ListString, tt, t.Cell(2, 1).Range, t.Cell(2, 2).Range
                          End If
                          Next
                          MsgBox "ok"
                          End Sub


                          13楼2017-04-02 21:10
                          回复
                            Getsetting savesetting 获取,保存配置


                            来自Android客户端14楼2017-10-25 08:26
                            回复
                              dtbl.Rows.Alignment=wdAlignRowCenter 设置表格居中


                              来自Android客户端15楼2018-06-25 17:03
                              回复