Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Treeview on a sheet

I've added a treeview to a sheet in excel, but I'm having problems using the
ImageList control to store and show images in the treeview control. I'd
successfully managed to get this to work when using it in a dialog, but
unfortunately this is not the case when it exists on a sheet rather than
within a form (this is within excel 2003 BTW)

Does anybody here know how to use imagelists with treeviews when the
treeview and imagelist exists on a sheet?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Treeview on a sheet

I neglected to show the line of code that isn't working:

Set ThisWorkbook.Sheets("Sheet1").OLEObjects("tvConten ts").Object.ImageList
= ThisWorkbook.Sheets("Sheet1").OLEObjects("ImageLis t").Object

(ImageList and tvContents obviously being the name of the image list and
treeview control respectively)

"PatrickS" wrote:

I've added a treeview to a sheet in excel, but I'm having problems using the
ImageList control to store and show images in the treeview control. I'd
successfully managed to get this to work when using it in a dialog, but
unfortunately this is not the case when it exists on a sheet rather than
within a form (this is within excel 2003 BTW)

Does anybody here know how to use imagelists with treeviews when the
treeview and imagelist exists on a sheet?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Treeview on a sheet

Also neglected to add that the error I was getting was 'Invalid object'.

"PatrickS" wrote:

I neglected to show the line of code that isn't working:

Set ThisWorkbook.Sheets("Sheet1").OLEObjects("tvConten ts").Object.ImageList
= ThisWorkbook.Sheets("Sheet1").OLEObjects("ImageLis t").Object

(ImageList and tvContents obviously being the name of the image list and
treeview control respectively)

"PatrickS" wrote:

I've added a treeview to a sheet in excel, but I'm having problems using the
ImageList control to store and show images in the treeview control. I'd
successfully managed to get this to work when using it in a dialog, but
unfortunately this is not the case when it exists on a sheet rather than
within a form (this is within excel 2003 BTW)

Does anybody here know how to use imagelists with treeviews when the
treeview and imagelist exists on a sheet?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Treeview on a sheet


Hello Patrick

i hope this helps you



Dim k As Byte, j As Byte
Dim Img1 As String, Img2 As String

Sheets(1).ImageList1.ListImages.Clear
Sheets(1).TreeView1.Nodes.Clear

Img1 = ThisWorkbook.Path & "\LeChat.bmp"
Img2 = ThisWorkbook.Path & "\2053851.jpg"

Sheets(1).ImageList1.ListImages.Add 1, "Image1", LoadPicture(Img1)
Sheets(1).ImageList1.ListImages.Add 2, "Image2", LoadPicture(Img2)

Set Sheets(1).TreeView1.ImageList = Sheets(1).ImageList1

For k = 1 To 5
Sheets(1).TreeView1.Nodes.Add , , "maClé1" & k, "ParentNode" & k,
"Image1", "Image2"
Next

For j = 1 To 5
For k = Sheets(1).TreeView1.Nodes.Count To
Sheets(1).TreeView1.Nodes.Count + 2
Sheets(1).TreeView1.Nodes.Add "maClé1" & j, tvwChild, "maClé2" &
Str(k), _
"ChildNode" & k, "Image1", "Image2"
Next
Next


regards
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=538037

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Treeview on a sheet

Thanks for that, but it's not working for me. I had to change the code anyway
as I don't have the option of storing the images externally, so using
LoadPicture is not possible in this case unfortunately. The images are stored
on one sheet and the code I'm uising ATM is this:

sub BuildImageList()
Dim i As Integer
Dim ws As Worksheet
Dim arrObjName

Set ws = ThisWorkbook.Sheets("Sheet2")
ws.Visible = xlSheetVisible
arrObjName = ws.Range("AE10:AE13").Value

ws.OLEObjects("TreeviewImages").Object.ListImages. Clear
For i = 1 To 4
ws.OLEObjects("TreeviewImages").Object.ListImages. Add Key:="img" &
i, Pictu=ws.OLEObjects("Image" & i).Object.Picture
Next
Set ThisWorkbook.Sheets("Sheet1").tvContents.ImageList =
ThisWorkbook.Sheets("Sheet1").TreeviewImages
Set ws = Nothing
End Sub

I used your syntax when it came to assigning the image list, but it came
back with the 'object does not support property or method' error.

"michelxld" wrote:


Hello Patrick

i hope this helps you



Dim k As Byte, j As Byte
Dim Img1 As String, Img2 As String

Sheets(1).ImageList1.ListImages.Clear
Sheets(1).TreeView1.Nodes.Clear

Img1 = ThisWorkbook.Path & "\LeChat.bmp"
Img2 = ThisWorkbook.Path & "\2053851.jpg"

Sheets(1).ImageList1.ListImages.Add 1, "Image1", LoadPicture(Img1)
Sheets(1).ImageList1.ListImages.Add 2, "Image2", LoadPicture(Img2)

Set Sheets(1).TreeView1.ImageList = Sheets(1).ImageList1

For k = 1 To 5
Sheets(1).TreeView1.Nodes.Add , , "maClé1" & k, "ParentNode" & k,
"Image1", "Image2"
Next

For j = 1 To 5
For k = Sheets(1).TreeView1.Nodes.Count To
Sheets(1).TreeView1.Nodes.Count + 2
Sheets(1).TreeView1.Nodes.Add "maClé1" & j, tvwChild, "maClé2" &
Str(k), _
"ChildNode" & k, "Image1", "Image2"
Next
Next


regards
michel


--
michelxld
------------------------------------------------------------------------
michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367
View this thread: http://www.excelforum.com/showthread...hreadid=538037


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TreeView Stephen[_22_] Excel Programming 2 October 10th 05 06:25 PM
Treeview Patrick Choi[_2_] Excel Programming 1 September 6th 04 08:29 AM
How to Treeview in VBA kvenku[_9_] Excel Programming 1 May 27th 04 01:03 PM
TreeView marijan glavac[_2_] Excel Programming 2 April 30th 04 07:28 AM
Treeview Max Scott Excel Programming 2 October 3rd 03 02:00 PM


All times are GMT +1. The time now is 11:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"