Hi,
I'm trying to rename my pipe network using excel. So far i've come to this piece of code:
Dim handle As String i = 2 handle = sheetStructures.Cells(i, 1).Value Do Set obj = ThisDrawing.HandleToObject(handle) Set struct = obj struct.Name = sheetStructures.Cells(i, 2).Value i = i + 1 handle = sheetStructures.Cells(i, 1).Value Loop While handle <> ""
The problem is that the code suddenly stops after this instruction:
struct.Name = sheetStructures.Cells(i, 2).Value
it works fine for the first structure, but then it suddenly stops, as if I had coded "Exit"...
do you know what's happening?
Thanks
Solved! Go to Solution.
Solved by ruipfbarreiros. Go to Solution.
can you help?
should have posted this in the customization forum...sorry about that
Post in the other forum and maybe include a sample excel file, full code, & dwg to test with. Although it looks like you are using VBA, and I'm not sure there a very many people who have installed the VBA enabler (I know I haven't since it slows down 64 bit installs).
i figured it out!
the problem was that as the code loops through the different structures, it renames those structures one by one, meaning that when it tries to rename structure #45 to #46 for example and structure #46 already exists, it fails no rename so that the two structures don't have the same name, and it quits the code without warning.
The solution is to rename the structures from the bottom up, that is to say, from the highest to the lowest number so that the situation described above doesn't happen!
Thank you anyway