How do I call a OfficeCodeBehind Program from a Button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I call a OfficeCodeBehind Program from a Button?

The program calls a Word.doc. There is no form to call a new instance of.
 
Hi Leo,

I did not understand your meaning very well.
Do you mean you wants to call a macro in a word document from a .net
application?
If so, I think you may try to call the Application.Run method, where the
application is the word application instance which you automation from .net
application.

Or can you describe your senario more detailed?


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.
 
Hi Leo,

I am sorry if I have any confusion.
The application object I means is the Word application not the application
in the .net framework.
Here goes the code snippet.
Sub Main()
Dim wdApp As Object = CreateObject("Word.Application")
wdApp.Documents.Add("c:\test.doc")
wdApp.Run("TestMacro")
End Sub

The code will open c:\test.doc and then run the testmacro in the test.doc.
You may have a try and let me know the result.

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.
 
Hi Leo,

I am sorry for misunderstanding your meaning.
I think we can consider the OfficeCodeBehind assembly as a managed Addin
compared with the COM Addin, or the compiled MACRO compared with the VBA
macro.
For office 2003, the word or excel unmanaged COM DLL (OTkLoadr.dll) to load
the CLR and the CodeBehind assembly, and it will then called the _
Startup and _ShutDown method in the OfficeCodeBehind assembly, we can
consider it as the entrypoint of the OfficeCodeBehind assembly. So we do
not need to call the officecodebehind directly, when we open the word or
excel file, the codebehind dll associated with it will be loaded and
executed automatically.

We can display a winform in the codebehind as the links below.
Walkthrough: Collecting Data Using a Windows Form
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/h
tml/wrwlkUsingWinFormToObtainUserInput.asp


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.
 
Peter,

Thanks for the help...... I did not realize how the .net code traveled with the Word Document. I Thought I had to open it run the code from the office codebehind. It is know working great thanks again.
 
Back
Top