+ Reply to Thread
Results 1 to 23 of 23

Parse Function

  1. #1
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Parse Function

    I'm using Excel 2007.I'm trying to retrive the body of messages inside a folder called Erika to an Excel sheet. The code run without errors but does not parse. As I step through the code my ParseTextLinePair is always "". Can anyone help me?

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 12-29-2007 at 04:57 AM.

  2. #2
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Bump

    Happy New Year!!

    I have posted this question at this location http://www.mrexcel.com/forum/showthread.php?t=293849
    but I didn't get any help. I just need help with the parse function. Up to this point I know its working.
    Please Login or Register  to view this content.
    I can see my source and my label but when I get to this line.
    Please Login or Register  to view this content.
    intLocLabel always = 0
    Any Ideas or suggestions?
    Thank you

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    It means the label does not appear in the string. If case is causing the problem, change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Function

    Hi and thank you for your help. I didn't get a chance to try it because this morning after running this code without an error now I'm getting an error.
    Please Login or Register  to view this content.
    Error (Compile error: User-defined type not defined)
    Any Ideas?

  5. #5
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Function

    The problem I was having happen because I move my macro to my personal.XLSB and before I was running my macro from Outlook.XLSM. Don't understand why It doesn't work in my personal file like the other macros. I tried the code you provided me and It's giving me a type mismatch error.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Please Login or Register  to view this content.
    Error (Compile error: User-defined type not defined)
    You need a reference to the Microsoft Outlook Object Library.
    I tried the code you provided me and It's giving me a type mismatch error.
    What code?
    Last edited by shg; 12-31-2007 at 02:27 PM.

  7. #7
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Function

    This is the one giving me the type mismatch error
    Please Login or Register  to view this content.
    Thank you

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I don't understand that. In the VBE Immediate window, type

    ? vbtextcompare

    It should show "1" (sans quotes).

    If it doesn't (???), replace the named constant in the code with 1.

  9. #9
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse function

    I type
    Please Login or Register  to view this content.
    and I got a 1

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Change the line to
    Please Login or Register  to view this content.
    If it still always returns 0, it means that the substring is not contained in the search string.

    Edit: BTW, in your code, mbox, inbox, strClient, strSales, and SAM are not declared -- that practice will bite you someday. I strongly recommend that you put Option Explicit at the top of every module so you have to declare all variables.
    Last edited by shg; 12-31-2007 at 05:34 PM.

  11. #11
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Function

    I corrected the code put Option Explicit at the top of every module, and declare all my variables mbox, inbox, strClient, strSales, and SAM. Modify the line of code like you said.
    Please Login or Register  to view this content.
    I didn't get any errors and retuned a 1. Still not parsing. The other thing I notice is this line of code.
    Please Login or Register  to view this content.
    intLocLabel always = 0 and then goes straight to the End If. Thank you for all your help.

    Happy New Year!!!

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Happy new year to you as well, Angel.

    Set a breakpoint on the Instr line, and look at the two strings. If the second string is not contained in the first, the function will return 0.

  13. #13
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Function

    Hello,
    I set a break point at
    Please Login or Register  to view this content.
    my strSource contained my strLabel.
    Thank you,

  14. #14
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Funtion

    Bump
    Still need assistance.

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Angel the Instr function works; if it returns zero, it is because the substring is not within the string being searched.

    The problem with helping is that most people won't want to have an untested program messing in their Outlook folders. If you can cut an example down to something that illustrates the problem standalone, someone might be more likely to.

  16. #16
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Function

    Will do on Monday because the macro is on Microsoft Office 2007 and I'm running Microsoft Office 2003 plus I don't have outlook.
    Thank you,

  17. #17
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Function

    Bump

    Ok here is what I see in my Locals Window

    After this line of code

    Please Login or Register  to view this content.
    This what I get

    : : <No Variables> :

    : strSource : "Index:
    Enterprise
    Commercial
    There are no items to report for this section.
    Public
    AFOTEC/KIRTLAND AFB
    University of Kansas
    Picatinny Arsenal
    Hoosier Lottery
    Basic and Sil"
    : strLabel : "Index: " : String
    : ParseTextLinePair : Empty : Variant/Empty
    : intLocLabel : 0 : Integer
    : intLocCRLF : 0 : Integer
    : intLenLabel : 7 : Integer
    : strText : "" : String
    After this line of code
    Please Login or Register  to view this content.
    This is what I get
    : strText : "" : String
    After this line then it goes to the second End IF

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I see a trailing space in strLabel "Index: ". Is there a space after "Index:" in strSource?

  19. #19
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Function

    You were right I dad a trail space that wasn't supposed to be there. I removed the trail space. Still not parsing.

    Thank you

  20. #20
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Just to repeat my earlier post:
    Angel the Instr function works; if it returns zero, it is because the substring is not within the string being searched.

    The problem with helping is that most people won't want to have an untested program messing in their Outlook folders. If you can cut an example down to something that illustrates the problem standalone, someone might be more likely to.

  21. #21
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Try this routine. I've attached a spreadsheet that you can use to test it. If it does what you want, plug it in to your other code.
    Please Login or Register  to view this content.
    Last edited by shg; 01-07-2009 at 11:47 AM.

  22. #22
    Registered User
    Join Date
    11-30-2007
    Posts
    44

    Smile Parse Function

    Great, you are the greatest. Thanks a lot. I'm retreving my email to one cell which is not a big deal but the first line of the 2 email I retreved are partially hidden.

    Thanks for all the great help!

  23. #23
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    You're welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1