Visio Group Settings

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

We are having a problem with a German version of Visio when trying to set
the "DontMoveChildren" cell of the Group Properties for a number of shapes
that are grouped together and then placed on a stencil. We try to set the
"DontMoveChildren" to "TRUE" when the group is dropped on to the drawing.
It seems that Visio generates an error that is not captured and the rest of
the code following this is not executed. We suspect that the problem is
with the "Local" name versus the "Universal" name.

Has anyone else had this problem, or one that is similar, and if so, would
you be willing to share your solution?
 
M

Markus Breugst

Hello,

could you please provide some lines of your code? For example, the line in
which your application obtains the shape reference and the line in which you
set the property.

Thanks & regards,
Markus
 
M

msnews.microsoft.com

Thank you for responding.

The code that we use is written in VB6 as follows.

Set cell = shp.Cells("DontMoveChildren")
cell.Formula = True

When running the program on a computer with German Visio, the code fails
at "cell.Formula = True". We were able to determine this by setting message
boxes to display after each line is executed since we do not have a copy of
German Visio. The problem was reported by a person that is using German
Visio. The code is executed from an ActiveX in process dll.

Because you are in Germany, it would be interesting to see if you also have
a problem with this. Thanks in advance for looking at it.
 
M

Mark Nelson [MS]

Are you using VBA? There is a long-standing bug in VBA (not
German-specific) that suppresses some types of automation errors and stops
code execution. Regardless, if you post some details, there are many
helpful people on the forum who might be able to assist with the original
problem.
 
M

msnews.microsoft.com

Hi Mark,

Thanks for the response. As I replied to Markus, our code is in an ActiveX
dll
as follows.

Set cell = shp.Cells("DontMoveChildren")
cell.Formula = True

When running the program with German Visio, the code fails at

cell.Formula = True

We think that changing the code to: cell.FormulaU = True
will solve the problem; however, we are not sure and we had some
indication that this may not be the solution; however, we are
waiting for a reply from our German user to see what he finds
from a test document that we sent to him. We do not have this
problem on any English versions of Visio - everything works as
it should.

Any information that you can give us would be helpful.

Thanks in advance.
 
M

Markus Breugst

Hi again,

I tried it with a German Visio version, and it worked without problems.
Here's my complete test code. ("Sheet.3" is the group shape.)

Public Sub DontMove()
Dim myShape As Shape
Dim myCell As Cell
Set myShape = ThisDocument.Pages(1).Shapes("Sheet.3")
Set myCell = myShape.Cells("DontMoveChildren")
myCell.Formula = True
End Sub

Best regards,
Markus
 
M

msnews.microsoft.com

Dear Markus,

Thank you for trying this and letting me know the results. It is a strange
problem in that we sent a test model to our client with code to see if he
could duplicate the problem and he can; however, we cannot not duplicate
it, nor can Microsoft technical help, nor you. When our client runs the
test example that we made for him, he gets a runtime error: '2032466907
(86db0425)':#name? This runtime error occurs when he runs the code and it
tries to change the "DontMoveChildren" to True from False. He can open the
shapesheet and change the value manually without a problem.

I thought that he was using MS Visio German, but it turns out that he is
using MS Visio 2002 Professional English version 10.0.2514 which is the same
version of Visio that we are using to test the code, and with which we do
not get the problem. He is also using MS Windows XP Professional version
5.1.2600 Service Pack 1 Build 2600.

At the moment, we are stumped unless it is some problem with the VBA dll
that he has on his machine.

Thanks for your help.
 
M

msnews.microsoft.com

It seems that the solution to the problem is to use and integer to set the
cell instead of True. The following code works

Set cell = shp.Cells("DontMoveChildren")
cell.Formula = 1

But using

Set cell = shp.Cells("DontMoveChildren")
cell.Formula = True

gives a runtime error on some machines.
 
M

msnews.microsoft.com

It seems that the solution to the problem is to use and integer to set the
cell instead of True. The following code works

Set cell = shp.Cells("DontMoveChildren")
cell.Formula = 1

But using

Set cell = shp.Cells("DontMoveChildren")
cell.Formula = True

gives a runtime error on some machines. Is this some sort of Visio bug?
 
M

Mark Nelson [MS]

You should definitely be using the universal versions of the Visio
automation methods when writing an application that is used in multiple
languages or locales. While Visio has tried to smooth out some rough spots,
universal syntax is the only way to ensure things work properly.

shp.Cells("DontMoveChildren") presumes that there is a cell in all language
versions of Visio by that name. In the past Visio translated all cell
names, so this cell might have been named "NichtGehenKindern" (making
something up here) in the German product. Therefore, your cell name would
not be found and Visio would throw an error. Use the universal method
CellsU to specify a cell name that is guaranteed to exist everywhere.
shp.CellsU("DontMoveChildren") should always work.

Likewise when setting a formula, use universal syntax. For example, the
formula "=IF(Width>0,1,2)" is not going to work well if the function IF is
not translated as "IF" or the cell "Width" is not translated as "Width".
Also the German locale uses semi-colons to separate arguments instead of
commas. To make sure that your formula will work, use FormulaU. Then pass
in the standard function names, cell references and punctuation that is used
in the English product.

One final issue which might explain the odd difference between assigning a 1
versus True to a cell: The Formula and FormulaU properties take String
expressions. By assigning the integer 1 or the boolean True to this
property, the compiler must cast this information as a string. This may
result in different outcomes. To be safe, pass the string type yourself.

--
Mark Nelson
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top