Results 1 to 11 of 11

Thread: [SOLVED] Save Treeview content into Text file

  1. #1

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Question [SOLVED] Save Treeview content into Text file

    Hi there,

    Any idea to Save Treeview content into Text file?

    I wish to be able to save it in this style:

    Code:
    [Caption 1]
    - Element 1
    - Element 2
    
    [Caption 2]
    - Element 1
    - Element 2
    
    [Caption 3]
    - Element 1
    - Element 2
    Thank you!
    Last edited by beic; Apr 4th, 2023 at 04:17 PM.

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,525

    Re: Save Treeview content into Text file


  3. #3

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: Save Treeview content into Text file

    Quote Originally Posted by jdc2000 View Post
    Hardly, it's for .NET

  4. #4
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,525

    Re: Save Treeview content into Text file


  5. #5

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: Save Treeview content into Text file

    Quote Originally Posted by jdc2000 View Post
    I'm getting "Banned IP Address", can't load the actual page.

  6. #6
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,525

    Re: Save Treeview content into Text file

    Link:

    Code:
    https://www.fortypoundhead.com/showcontent.asp?artid=48970
    It sounds like your IP address is the banned one at that site. Try using a VPN to access it.

    This is for VBA, but it should be similar to what you are looking for:

    https://www.excelforum.com/excel-pro...-with-vba.html

    http://vbcity.com/forums/t/6989.aspx

  7. #7

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: Save Treeview content into Text file

    Quote Originally Posted by jdc2000 View Post
    It sounds like your IP address is the banned one at that site. Try using a VPN to access it.

    http://vbcity.com/forums/t/6989.aspx
    It seems too, weird think...

    And big thank to you for helping me out here, I managed to get what I wish from the last link, but I can't figure out how to put new line after every new section.

    Code:
    Public Sub SaveTreeViewToFile(objTW As TreeView, stFilename As String)
     
     Dim mNode As node
     Dim mChild As node
     
     Dim frFile As Integer
    
     frFile = FreeFile
    
     Open stFilename For Output As #frFile
      For Each mNode In objTW.Nodes
         If mNode.Children > 0 Then
             Print #frFile, "[" & mNode.Text & "]"
             For Each mChild In objTW.Nodes
                 If mChild.Children = 0 Then
                     If mChild.Parent.Key = mNode.Key Then
                         Print #frFile, "- " & mChild.Text
                     End If
                 End If
             Next
         End If
      Next
     Close #frFile
    
     Exit Sub
    End Sub

  8. #8
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,525

    Re: Save Treeview content into Text file

    Code:
    Public Sub SaveTreeViewToFile(objTW As TreeView, stFilename As String)
     
     Dim mNode As node
     Dim mChild As node
     
     Dim frFile As Integer
    
     frFile = FreeFile
    
     Open stFilename For Output As #frFile
      For Each mNode In objTW.Nodes
         If mNode.Children > 0 Then
             Print #frFile, "[" & mNode.Text & "]"
             For Each mChild In objTW.Nodes
                 If mChild.Children = 0 Then
                     If mChild.Parent.Key = mNode.Key Then
                         Print #frFile, "- " & mChild.Text
                     End If
                 End If
             Next
             Print #frFile, ""
         End If
      Next
     Close #frFile
    
     Exit Sub
    End Sub

  9. #9

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: Save Treeview content into Text file

    Thank you so much! <3

  10. #10
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,294

    Re: [SOLVED] Save Treeview content into Text file


  11. #11

    Thread Starter
    Addicted Member beic's Avatar
    Join Date
    Jun 2012
    Posts
    176

    Re: [SOLVED] Save Treeview content into Text file

    Quote Originally Posted by dz32 View Post
    Just viewed it, it's great, but to much for my need, thank you!

Tags for this Thread

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