Closed Thread
Results 1 to 30 of 30

Get Treeview selected node into a string.

  1. #1
    abhay_547
    Guest

    Get Treeview selected node into a string.

    Hi All,

    I have the below macro which downloads the attachments from a particular folder of outlook. It works perfectly but the only thing is that I need to hardcode the folder name in the below macro which I don't want to do. I thought use the inputbox method so that user can enter the folder name and then macro can download the attachments from that folder which user has entered in inputbox but the user may or may not enter the folder name correctly, so I thought to come up with a userform which will show the Treeview of all outlook folder on the userform and the user will the select the folder from the treeview but I am unsure that how do I use the treeview node selected by the users as a string and use the same in my code in such a way that the code downloads the file from the selected folder.

    Please Login or Register  to view this content.
    So far I have the below code which I got from a google search the below code loops through the treeview and checks which node is selected by user. Please help...

    Please Login or Register  to view this content.
    Thanks a lot for your help in advance.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Get Treeview selected node into a string.

    can you not use

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Get Treeview selected node into a string.

    Something like this any good?

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  4. #4
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,

    Thanks a lot for your reply, But I am unable to incorporate the code line provided by you in my code. I tried the below things but it didn't work. Here is what I tried.

    1)
    Please Login or Register  to view this content.
    . This didn't work.

    2)
    Please Login or Register  to view this content.
    ' Even this didn't work.

    Thanks a lot for your reply in advance.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Get Treeview selected node into a string.

    If anything it would be,

    Please Login or Register  to view this content.

  6. #6
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Domski,

    Thanks a lot for your reply, Can you please let me know how can I incorporate the code lines provided by you to get the user selected item as a string from treeview of my userform.


    Thanks a lot for your help in advance.

  7. #7
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,

    Thanks a lot for your reply, I have tried to incorporate the below code posted by you but it's still not working. Please help..

    Please Login or Register  to view this content.
    Thanks a lot for your help in advance.

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Get Treeview selected node into a string.

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!

    Read this to understand why we ask you to do this
    Remember what the dormouse said
    Feed your head

  9. #9
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi romperstomper,

    Thanks a lot for your reply, I will ensure the same going forward.

  10. #10
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Get Treeview selected node into a string.

    Maybe like this:

    Please Login or Register  to view this content.

    Dom

  11. #11
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Domski,

    Thanks a lot for your reply, I tried to run the code provided but it doesn't work. It throws a error message. .i.e. variable not found. It gets stuck on the below line and highlights the ThisOutlookSession word. I have selected the references to Microsoft Outlook xx object library and Microsoft Outlook xx view control as well in my vba project. please help.

    Please Login or Register  to view this content.
    Thanks a lot for your help in advance.

  12. #12
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Get Treeview selected node into a string.

    Maybe:

    Please Login or Register  to view this content.

    Dom

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Get Treeview selected node into a string.

    Post an example workbook

  14. #14
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Get Treeview selected node into a string.

    and please add a link to your cross posts.

  15. #15
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Domski,

    Thanks a lot for your reply, but the macro is not downloading any attachments now as it use to do earlier. I have certain excel attachments in my one of outlook subfolder which I selected in the popup which appeared after I ran the modified code provided by you. Please help..

    Cross post link : http://www.mrexcel.com/forum/showthread.php?t=506948

    Thanks a lot for your help in advance.
    Last edited by abhay_547; 11-05-2010 at 08:27 AM.

  16. #16
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,

    Thanks a lot for your reply, Please find the attachment for my macro file.

    Thanks a lot for your help in advance.

  17. #17
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Get Treeview selected node into a string.

    The gets you to the stage of accessing the sub folder.

    Userform code
    Please Login or Register  to view this content.
    Module1 code
    Please Login or Register  to view this content.

  18. #18
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,


    Thanks a lot for your reply, I have incorporated code posted by you in my main macro file but it's still not working can you please look into my file. I have attached it for your reference.

    One more thing can we select the multiple folders and download the files from multiple folders at one go.

    Thanks a lot for your help in advance
    Attached Files Attached Files

  19. #19
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Get Treeview selected node into a string.

    What does, "still not working" actually mean.

    I just tried the code and it worked fine if used as coded. That is you still have to enter the folder name in textbox1.

    Seems unrealistic to worry about multiple selection when you report that the code does not even work.

  20. #20
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,

    Thanks a lot for your reply, When I say that it's not working I mean to say it's not downloading the files as it use to do earlier. It just shows me a message box when I run the macro with the text .i.e. myfolder has 9 items folder. that's it and then it shows a error message. I have attached the error screenshot for your reference.

    Thanks a lot for your help in advance.
    Attached Images Attached Images

  21. #21
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Get Treeview selected node into a string.

    This will simply list the emails and their attachment file names.

    Please Login or Register  to view this content.

  22. #22
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,

    Thanks a lot for your reply, the code posted by you shows the msgboxes and shows the attachments names but it doesn't download those file. Please help...

    Thanks a lot for your help in advance.

  23. #23
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Get Treeview selected node into a string.

    Sounds like you just want somebody to do it rather than help you.

    Have you tried understanding the code post by everybody in your thread?

  24. #24
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,

    Thanks a lot for your reply, I tried to workout with the code provided by you but it's not working and showing me the same error the screenshot of which I had attached earlier. It shows me the message box with 9 items found and then it shows me the error message.

    Here is the code which I had worked out using the code provided by you.

    Please Login or Register  to view this content.
    Thanks a lot for your help in advance.
    Last edited by abhay_547; 11-06-2010 at 01:40 AM.

  25. #25
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,

    Did you get the chance to look into my above post ?

    Thanks a lot for your help in advance.

  26. #26
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi All,

    I was finally able to figure out the error issue from my end and here is the final code. The below code works absolutely fine. I can download the files from a selected outlook folder but I still have one more issue which I am unable to fix .i.e. if I select more then one subfolders in treeview it doesn't allow me to do that. I have changed the treeview properties so that it shows me the check boxes. Please help. I have attached my final macro file for your reference.

    Code in my userform .i.e. frmdownloadattchmts :
    Please Login or Register  to view this content.


    Code in my module :
    Please Login or Register  to view this content.
    Thanks a lot for your help in advance.
    Attached Files Attached Files

  27. #27
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Get Treeview selected node into a string.

    You can loop through the nodes checking for selected nodes.

    Please Login or Register  to view this content.
    You need to make a slight change to the GetAttachments routine
    Please Login or Register  to view this content.

  28. #28
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,

    Thanks a lot for your reply, I have incorporated the modified code posted by you in main macro but unfortunately still it's downloading the files from only one folder at a time. It doesn't download the files from multiple folders even though if I select them in the treeview using checkboxes. Please help..

    Code in Commandbutton event :
    Please Login or Register  to view this content.

    Code in Module :
    Please Login or Register  to view this content.
    Thanks a lot for your help in advance.

  29. #29
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Get Treeview selected node into a string.

    yeah, try the Checke property rather than the selected one.

    Please Login or Register  to view this content.

  30. #30
    abhay_547
    Guest

    Re: Get Treeview selected node into a string.

    Hi Andy,

    Thanks a lot for your reply, It works fine now. You are just awesome. But still there is a small issue .i.e. after downloading the files from each folder it shows a msgbox that it has downloaded the files which is what I want to suppress I it to show the download completion message once. Here is the part of code which is creating this issue.

    Please Login or Register  to view this content.
    Thanks a lot for your help in advance.

Closed 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