[WORD 2003] Opening Word from Outside Prog
Hey all,
I'm new to using the references and all to do things within VB.Net. What I'm trying to do is open Word 2003 from another program, without Word opening visibly to the user. I figure thats just an easy one line property change. However I'm not sure what references are needed. I have tried many ways and on several computers. I gave up on my last few projects and handed them off to another. I was told that I need to add the reference COM/PIA for the interop. I've searched the references and cannot find it. The furthest down the chain I seem to be able to get is Microsoft.Office and the only things found after Office is Core, which has nothing below it. I'ved asked a bunch of forums the same basic question and most of them say I'm doing it wrong and won't tell me the right way.
I have currently installed Visual Basic 2005 Express Edition and Microsoft Office Word 2003. There are no add-ons, plug-ins or the like installed on either. For an operating system I am running Windows MCE with a partitioned Ubuntu that I use for learning *nix and such. So all programming and the like is done on the Windows MCE platform.
Re: [WORD 2003] Opening Word from Outside Prog
I use Excel from my .NET apps, but I image the process is the same.
Click Project/Add Reference
Click the COM tab
Find Microsoft Word 11.0 Object Library
Click OK
Re: [WORD 2003] Opening Word from Outside Prog
Hack,
I'd use Excel, however I need to work with .doc files, so using Excel would add more problems in my opinion. As for adding the object I have and all I get in response is the addition of Microsoft.Office and Microsoft.Office.Core, there is no Interop.
Re: [WORD 2003] Opening Word from Outside Prog
Hack,
I have an error, I'm able to 'open' the document, however my program spits back an error about the documents permissions. Here's the full error detail:
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2146823167
HelpLink="C:\Program Files\Microsoft Office\OFFICE11\1033\wdmain11.chm#24601"
Message="Word experienced an error trying to open the file.
Try these suggestions.
* Check the file permissions for the document or drive.
* Make sure there is sufficient free memory and disk space.
* Open the file with the Text Recovery converter."
Source="Microsoft Word"
StackTrace:
at Microsoft.Office.Interop.Word.Documents.Open(Object& FileName, Object& ConfirmConversions, Object& ReadOnly, Object& AddToRecentFiles, Object& PasswordDocument, Object& PasswordTemplate, Object& Revert, Object& WritePasswordDocument, Object& WritePasswordTemplate, Object& Format, Object& Encoding, Object& Visible, Object& OpenAndRepair, Object& DocumentDirection, Object& NoEncodingDialog, Object& XMLTransform)
at PNAT_Creator.PNATCreator.btnPrint_Click(Object sender, EventArgs e) in I:\PNAT Creator\PNAT Creator\PNATCreator.vb:line 167
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at PNAT_Creator.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Re: [WORD 2003] Opening Word from Outside Prog
Didnt we already resolve this issue? Wasnt it that you have multiple Word versions installed or something?