Visual Basic RightClick Context Menu

J

Joda-oda

hi @ all,

i'm new in Automation...so i'm sry if my question aren't so professional.
What i want to do is, is to add an item in my right click context menu. When
i click on it, there should appear a message box.

ok, my code:


Imports Office = Microsoft.Office.Core
Imports Word = Microsoft.Office.Interop.Word

Public Class Form1

Dim oWord As Word.Application
Dim oButton As Office.CommandBarControl

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

oWord = New Word.Application

oWord.Visible = True

oWord.Documents.Add()


End Sub

Private Sub Loading()

oButton = oWord.CommandBars("Text").Controls.Add

With oButton

.Caption = "TEST"
.FaceId =
.OnAction =
.BeginGroup = True

End With

oButton = Nothing

End Sub

Private Sub Unloading()

oWord.CommandBars("Text").Controls("TEST").Delete()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Call Loading()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Call Unloading()

End Sub

my problems:

1) in my version, my programm opens everytime a new Word Window. But now i
want to
change the context menu of an opened Word document.

2) is there a way, that you can load a picture instead of using the faceid?

3) What do i have to wright after .OnAction? I tried it with the name of
an other Private Sub, but then word gets a makro error....

I, now these are a lot of question, but i really would appreciate it. THX
 

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