|
将原来加载宏中 - Private Sub Convertor(ByRef Txt, Hb As Boolean)
- Dim Lf As Long, Tp As Long, Wd As Long, Ht As Long, i As Long, Falg As Boolean, Flag As Boolean
- Dim Tmp As String, K&, StartLine&, J&, Hr&, Pr, Mt&
- Dim CodeMod As CodeModule, Pane As CodePane
- Dim HrLine()
- On Error GoTo 0
- If Application.VBE.MainWindow.Visible = False Then
- MsgBox "执行本程式请先开启VBE视窗", vbCritical, AppName
- Exit Sub
- End If
- Set Pane = Application.VBE.ActiveCodePane
- If Err.Number <> 0 Then
- MsgBox "您未勾选信任存取 Visual Basic 专案", vbCritical, AppName
- Exit Sub
- End If
- Set CodeMod = Pane.CodeModule
- '取得每个程序的所在列(日后THML要插入水平线的列数)
- With CodeMod
- K = 0
- StartLine = .CountOfDeclarationLines + 1 '略过宣告区
- Do Until StartLine >= .CountOfLines
- StartLine = StartLine + _
- .ProcCountLines(.ProcOfLine(StartLine, vbext_pk_Proc), _
- vbext_pk_Proc)
- ReDim Preserve HrLine(K)
- HrLine(K) = StartLine
- K = K + 1
- Loop
- End With
- Lf = 1
- Ht = CodeMod.CountOfLines '全部程式码的列数
- '档名 & 模组名称
- Txt = "<head><title>" & Pane.Window.Caption & _
- "- Html" & "</title></head>"
- ' Verdana 字体
- Txt = Txt & "<font face=Verdana size=2>"
- IExp.document.writeln Txt
- For i = 1 To Ht
- Tmp = CodeMod.Lines(i, 1)
- If Trim(Tmp) <> "" Then
- If Not (Flag Or Left(Trim(Tmp), 1) = "'" Or Len(Trim(Tmp)) = 0) Then
- If Right(Trim(Tmp), 2) = " _" Then Flag = True Else Flag = False
- Select Case Split(Trim(Tmp), " ")(0)
- Case "Sub", "Function"
- J = 0
- Case "Private", "Public"
- Select Case Split(Trim(Tmp), " ")(1)
- Case "Sub", "Function"
- J = 0
- End Select
- End Select
- J = J + 1
- If Hb Then Tmp = "<SPAN style=" & Chr(34) & " color:FF0000" & Chr(34) & "> #" & Format(J, "000") & " </SPAN>" & Tmp
- ' If Hb Then Tmp = "<SPAN style=" & Chr(34) & " color:FF0000" & Chr(34) & ">" & Format(J, "000:") & "</SPAN>" & Tmp
- If J = 1 Then Tmp = "<SPAN style=" & Chr(34) & " color:007F00" & Chr(34) & ">" & " '撰写:" & NA_M & vbCrLf & " '网址:" & Http & vbCrLf & " '日期:" & Now & "</SPAN>" & vbCrLf & Tmp
- Else
- If Right(Trim(Tmp), 2) = " _" Then Flag = True Else Flag = False
- ' If Left(Trim(Tmp), 1) = "'" Or Len(Trim(Tmp)) = 0 Then Falg = False Else Falg = True
- End If
- If i <= CodeMod.CountOfDeclarationLines Then
- '处里宣告区的程式码
- ConvertCode Tmp, True
- Hr = CodeMod.CountOfDeclarationLines
- Else
- ' 处理主程序程式码
- ConvertCode Tmp, True
- Pr = CodeMod.ProcOfLine(i, vbext_pk_Proc)
- End If
- If i - 1 = Hr And Hr <> 0 Then
- '插入水平线 <" & "hr" & ">"
- IExp.document.writeln "<" & "hr" & ">"
- End If
- On Error Resume Next
- Mt = Application.WorksheetFunction.Match(i, HrLine(), 0)
- On Error GoTo 0
- If Mt > 0 Then
- IExp.document.writeln "<" & "hr" & ">"
- Mt = 0
- End If
- Txt = Tmp & "<" & "br" & ">"
- IExp.document.writeln Txt 'IIf(Flag Or j = 0, "", Format(j, "000:")) & Txt
- End If
- Next i
- IExp.document.writeln "</FONT>"
- End Sub
复制代码 中的一行代码作如下修改即可!
- If Hb Then Tmp = "<SPAN style=" & Chr(34) & " color:FF0000" & Chr(34) & "> #" & Format(J, "000") & " </SPAN>" & Tmp
-
复制代码 |
|