Results 1 to 7 of 7

Thread: Help PLEASE!!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    7

    Arrow Help PLEASE!!!

    I am having problems with this code every time I run the code I get an error when this loop runs. what I am trying to do is pick up anything that appears between the words application and platform for example (platform blah, blah, blah, application)and when i run the loop after it finds the first case it gives me an error saying "Ivalid procedure call or argument". heres a copy of the code an i=2105 and j=553
    PHP Code:
    Sub test1()
        
    Dim r As Range
        Dim rword 
    As Range
        Dim h 
    As LongAs Long
        Dim xlApp 
    As Excel.Application
        Dim xlWB 
    As Excel.Workbook
        
    'With ActiveDocument
        Dim seastring1 As String
        Let seastring1 = ThisDocument.Content
        
        Const seastring2 As String = "Application:"
        Const pook As String = "Platform:"
        
        


     
    Dim j As Long
    Dim i As Long

    j = InStr(seastring1, seastring2)
    i = InStr(1, seastring1, pook)
    Do While i <> 0





    MsgBox Mid$(seastring1, i, j - i), Len(Mid$(seastring1, i, j - i))
    '
    MsgBox pook i
    'MsgBox Mid$(seastring1, i, InStr(seastring1, seastring2) - i) 'Len(Mid$(seastring1iInStr(seastring1seastring2) - ))
    InStr(1seastring1pook)

    Loop
    'End With
    End Sub 
    Last edited by joi2; Nov 1st, 2005 at 08:51 AM.

  2. #2
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Help PLEASE!!!

    Code:
    MsgBox Mid$(seastring1, i, j - i), Len(Mid$(seastring1, i, j - i))
                                     ^
    I think the comma in this line is a problem ... it makes the "Len" part of the statement look like a code for a button. Replace it with something like { & " | " & } (without the braces).
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    7

    Re: Help PLEASE!!!

    no thats not the problem, someone told me that the mid$ functiopn cannot work with negative lenght could that be the prob because i is bigger than j?

  4. #4
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Help PLEASE!!!

    I didn't say it was "the" problem ... I said "I think (it) is a problem".
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    7

    Re: Help PLEASE!!!

    oh sorry

  6. #6
    Frenzied Member
    Join Date
    May 2004
    Location
    Carlisle, PA
    Posts
    1,045

    Re: Help PLEASE!!!

    That "Someone" was correct ... the error message you get is the message when the "Length" parameter of the Mid$ call is negative (j < i). This will always happen when i "walks" over j looking for the second occurrence of "Platform:". You 'move' i looking for the second occurrence of "Platform:", but you never move j. Why not?
    Blessings in abundance,
    All the Best,
    & ENJOY!

    Art . . . . Carlisle, PA . . USA

  7. #7

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Posts
    7

    Re: Help PLEASE!!!

    thank you so much that was the problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width