Word Document inside OLE object limitations

M

mbenetti

Dear Expert,

I have a problem with a Word Document used in a OLE object.
I need to create the toolbar on my personal dot file but when I try to
create a custom Word toolbar, the action seems to be blocked by some OLE
object restrictions.
Naturally it works fine when I use Word as a normal application.
I tested this behaviour with a OLE object inserted in a form of various
programming languages (Delphi, Java, ...).
Is it a restriction?
 
Y

Yan-Hong Huang[MSFT]

Hello mbenetti,

Sorry for the late response. This problem is quite complicated. We may need
to contact support team for some insight. Before that, could you please
provide us more informaton so that we can isolate the problem as soon as
possible?

1) Detailed repro steps on this issue?
2) If there is some simple sample which can demo it, that would be great.

Thanks very much for your patience. We are glad to work with you closely.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://msdn.microsoft.com/subscriptions/managednewsgroups/

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

mbenetti

My dot document is in the Startup folder.
When my costumers open the Delphi (Java, etc.) application with the Word
Document OLE object and click on my button in the Word toolbar, this code is
executed:

Dim oCmdBarControls As Office.CommandBarControls
Dim oCmdBar As Office.CommandBar

'toolbar creation
Application.CustomizationContext = ThisDocument
On Error Resume Next
Set oCmdBar = g_oWordApp.CommandBars("Test")
On Error GoTo error
If oCmdBar Is Nothing Then
Set oCmdBar = ActiveDocument.CommandBars.Add("Test", msoBarTop, , True)
End If
oCmdBar.Visible = False
Set oCmdBarControls = oCmdBar.Controls

'erase all controls
Do While oCmdBarControls.Count > 0
oCmdBarControls.Item(1).Delete
Loop

'adding controls
Set g_btnDettaturaAttiva = oCmdBarControls.Add(msoControlButton, ,
"Button1", 1, True)
Set g_btnDettaturaDisattiva = oCmdBarControls.Add(msoControlButton, ,
"Button2", 2, True)

'...

oCmdBar.Visible = True

Initially I used this code in an VB6 EXE ActiveX using the "As Object"
variables declaration and it gives me no error but it doesn't work with OLE.
After this I tryed it directly in Word and gave me
Error -2147467259: Method 'Add' of object '_CommandBars' failed
at line
Set oCmdBar = ActiveDocument.CommandBars.Add("Test", msoBarTop, , True)

I should make the code work with a VB6 EXE ActiveX and I can't modify OLE
host application.

Best regards,

Stefano
 
P

Peter Huang [MSFT]

Hi

Based on my research, this is more depended on the OLE host.
Here is link for a reference.
When we open document in IE( which is also a ole host) the menu insert will
failed, the menu is merged by IE.
http://groups.google.com/group/microsoft.public.vb.ole.automation/browse_frm
/thread/a4ef25431bbe40b4/24a859dca6062d0b?lnk=st&q=%22v-phuang%22+internet+e
xplorer+menu&rnum=1&hl=en#24a859dca6062d0b

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
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