当前位置: 代码迷 >> VBA >> 小弟我没办法了。还要麻烦大家帮忙解释代码了
  详细解决方案

小弟我没办法了。还要麻烦大家帮忙解释代码了

热度:4397   发布时间:2013-02-26 00:00:00.0
我没办法了。还要麻烦大家帮忙解释代码了。
   实在不好意思。我马上要把收集的这些材料上交了。可要我注释每段代码。有点难度。所以又来求助各位了。但愿不要闲烦。呵呵!!请帮帮忙。谢谢!!!

一、
     VB code 

Private Sub CommandButton1_Click()
    Dim i%, strFileName$, strDirectory$
    
    strDirectory = "E:\"
    
    strFileName = Dir(strDirectory, vbDirectory)
    Do While strFileName <> ""
        If strFileName <> "." And strFileName <> ".." Then
            If (GetAttr(strDirectory & strFileName) And vbDirectory) = vbDirectory Then
                i = i + 1
                Range("A" & i).Select
                ActiveCell.FormulaR1C1 = strFileName
            End If
        End If
        strFileName = Dir
    Loop
End Sub

二、
      VB code 

Sub GetNo()
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Dim i As Long
    For i = 1 To 10
        With Selection.Find
            .Text = "abc"
            .Replacement.Text = i & ".abc"
            .Forward = True
        End With
        With Selection
            If .Find.Forward Then
                .Collapse Direction:=wdCollapseStart
            Else
                .Collapse Direction:=wdCollapseEnd
            End If
            .Find.Execute Replace:=wdReplaceOne
            If .Find.Forward Then
                .Collapse Direction:=wdCollapseEnd
            Else
                .Collapse Direction:=wdCollapseStart
            End If
            .Find.Execute
        End With
    Next
End Sub

三、
  相关解决方案