Joda-oda
2009-03-04 20:03:03 UTC
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 shout be just 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
ok, this is a very simple Application, but enough for me right now.
my problems:
1) in my version, my programm opens everytime Word new. 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 an error....
I, now these are a lot of question, but i really would appreciate it. THX
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 shout be just 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
ok, this is a very simple Application, but enough for me right now.
my problems:
1) in my version, my programm opens everytime Word new. 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 an error....
I, now these are a lot of question, but i really would appreciate it. THX