B
Bernd
Hi,
I am developing a word addin, which basically consists of wrappers
for the WordApplication and WordDocument. In the VB6 era I installed
the addin each time before final testing. But with VB.NET I found a
way to test and debug it without installation:
Inside the debugger I simply execute a sub Main, which launches Word and
creates the WordApplication wrapper. After that I start a thread, which
simply waits for Word to terminate.
My WordWrapper adds a menu to the active menu bar. I can click on the
menu items and the wrapper reacted to the corresponding events. So far,
so good.
Recently I used the clipbord for inserting pictures into a document,
....and then trouble came in. The clipboard doesn't work since
it insists to run in a STA (single threaded apartment). I tried to
attribute like "<System.STAThread()> Sub InsertPicture", but nothing
changed.
The funny thing is that my sub Main starts as a STA. Unfortunately the
apartment state of the current thread switches to MTA as soon as the
event handler of my WordWrapper is executed:
Private Sub btNewDocument_Click(ByVal Ctrl As CommandBarButton, _
ByRef CancelDefault As Boolean) _
Handles btNewDocument.Click
Is there a solution to this at all?
Thanx a lot for your answers
Bernd
I am developing a word addin, which basically consists of wrappers
for the WordApplication and WordDocument. In the VB6 era I installed
the addin each time before final testing. But with VB.NET I found a
way to test and debug it without installation:
Inside the debugger I simply execute a sub Main, which launches Word and
creates the WordApplication wrapper. After that I start a thread, which
simply waits for Word to terminate.
My WordWrapper adds a menu to the active menu bar. I can click on the
menu items and the wrapper reacted to the corresponding events. So far,
so good.
Recently I used the clipbord for inserting pictures into a document,
....and then trouble came in. The clipboard doesn't work since
it insists to run in a STA (single threaded apartment). I tried to
attribute like "<System.STAThread()> Sub InsertPicture", but nothing
changed.
The funny thing is that my sub Main starts as a STA. Unfortunately the
apartment state of the current thread switches to MTA as soon as the
event handler of my WordWrapper is executed:
Private Sub btNewDocument_Click(ByVal Ctrl As CommandBarButton, _
ByRef CancelDefault As Boolean) _
Handles btNewDocument.Click
Is there a solution to this at all?
Thanx a lot for your answers
Bernd