Can't exit design mode because Control 'MyTextBox3' can not be created"

  • Thread starter Nickolai Medveditskov
  • Start date
N

Nickolai Medveditskov

I am trying to insert my control into Word 2003 and the results depend on
Word macro's security setting.

Code is following:
....
MSWORD::InlineShapesPtr shapes;
....
HRESULT hr = shapes->AddOLEControl(&controlType, &vEmpty, &shape);
....

1. Word security (Tools/Macro/Security) is set to 'Very High' - this code
inserts the control without problem.
2. 'High' - the same.
3. 'Medium' - not tested because it displays "Enable/Disable Macros" dialog;
2. 'Low' - the code shoes message box - "Microsoft Visual Basic", "Can't
exit design mode because Control 'MyTextBox3' can not be created".

What is unreasonable here, that higher security level works fine in place
where lower security does not work.

Why it is implemented in such way and how to workaround it?


Nickolai.
 
C

Charles Kenyon

High security isn't allowing your code to run and isn't bothering you by
telling you about it.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
N

Nickolai Medveditskov

Hello,

I am not using VBA to deal with Word macro's security. I call method of Word
COM object in C++ code of my AciveX control:

MSWORD::InlineShapesPtr shapes;
....
// from debuger: controlType = {"MyWordWrapper.MyTextBox.1" VT_BSTR} _variant_t

HRESULT hr = shapes->AddOLEControl(&controlType, &vEmpty, &shape); ...

This code works regardless macro's security level - it inserts my control
and returns S_OK as result. Only difference is here - message box with strange
diagnostics:

---------------------------
Microsoft Visual Basic
---------------------------
Can't exit design mode because Control 'MyTextBox3' can not be created
---------------------------

As I understand situation - InlineShapes.AddOLEControl(...)
- tries to create MyTextBox control and tries to use the name 'MyTextBox3'
- fails to use this name
- shows MessageBox with warning
- then creates successfully control with another name

"Illegal" control name is some-how reserved in document, because document
had control with this name before, but later this control was deleted. This
"illegal" name was left "reserved" in document - I see it in hex dump of
..doc file.

My aim is: to workaround this MessageBox when MS Word is in Low Level of
Macro Security.

Could you suggest the solution?


Nickolai.
 
C

Charles Kenyon

For an ActiveX control to work in Word requires vba. High secrurity is going
to clip this link.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
N

Nickolai Medveditskov

Hello,

I am hosting Word in my ActiveX and controlling document content with Automation.
I command to Word to insert my control with
ActiveDocument.InlineShapes.AddOLEControl("MyWordWrapper.MyTextBox.1")
This command in Low Level of Macro Security produces message box, that it
can not create control with name "MyTextBox3", but my document has not controls
at all.
Looks like this name can not be used. Control is created, but with another
name.

How I can eliminate this warning in Low Security Mode?


Nickolai.
 

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