Thread: Me.Path Error

    #1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    206
    Rep Power
    12

    Me.Path Error


    Hi all,

    if I try to run the following script, the error message:
    "Invalid use of Me keyword" occurs.

    Code:
    Sub walk()
      Dim szMyName As String
      Dim szMyPath As String
      Dim szActDoc As String
      Dim nCount   As Integer
      Dim fs       As Variant
      Dim szIdErrors As String
      
      '--- get the actuel file and path
      szMyName = Me.Name
      szMyPath = Me.Path & "\"
      
      Set fs = Application.FileSearch
      With fs
          .LookIn = Me.Path
          .FileName = "*.doc"
          If .Execute(SortBy:=msoSortByFileName, _
              SortOrder:=msoSortOrderAscending) > 0 Then
              For nCount = 1 To .FoundFiles.Count
                  szActDoc = .FoundFiles(nCount)
                  If szActDoc <> szMyPath & szMyName And _
                      Mid$(szActDoc, Len(szMyPath) + 1, 1) <> "~" Then
                      Documents.Open FileName:=szActDoc, ReadOnly:=True
                      szIdErrors = szIdErrors & szActDoc & vbCr & vbLf
                      '------------------
                      'handle tables here
                      '------------------
                      Documents(szActDoc).Close False
                  End If
              Next nCount
              'ActiveDocument.Content.InsertAfter szIdErrors & vbCr
          Else
              MsgBox "There were no files found."
          End If
      End With
    End Sub
    Does anybody know why?
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    use App.Path
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    206
    Rep Power
    12
    Thanks ... now it works.

IMN logo majestic logo threadwatch logo seochat tools logo