VBA FontPoints only works once

Hello

I have a very simple macro that when you have an open shot, you size a note in the title block according to the number of characters.

The useful area of the code is this (selecting the note and changing the font size):

boolstatus = Part.Extension.SelectByID2("Objet de détail220@Fond de plan1", "NOTE", 0, 0, 0, False, 0, Nothing, 0)
Part.FontPoints 16

On all the plans with which I tested, I noticed this.

On the first run (it doesn't matter if I selected a view, or if I'm in the title block), you can see the macro highlighting my note and changing its size.

If I change 16 of my macro by 12 for example, on the second run it works too.

On the other hand, if I modify the note by hand, the macro doesn't want to work anymore. Unless I double-click on the note and run the macro without leaving the selection, then I can exit the note and continue running the macro.

But as soon as I enter a value manually the macro doesn't want to work anymore...

Do you have any idea why?

 

Hello

 

First of all , what do you mean by 'a manual value'?

 

For me your execution problem comes from the 'False' and your selection, when you select your note if you deselect it you are not necessarily in the same place as at the beginning. You probably click on a view or other.

 

 

boolstatus = Part.Extension.SelectByID2("Plan détail220@Fond object1", "NOTE", 0, 0, 0, False, 0, Nothing, 0)

 

You might have to reset your selection at the beginning of the macro to select your note in the background. 

 

For the other notes, it is possible to be attached to a view that prevents any modification by the macro. In this case you would have to go through all the views of the document for it to be effective. 

 

Otherwise you also have the method to modify the document properties and leave the notes in 'use the document font' You will just have to make different properties according to your choices.

To really provide a fair analysis of your error, one line of code seems insufficient.

Attach the complete code and possibly a drawing that will be easier to tell or test the problem.

 

1 Like