Results 1 to 5 of 5

Thread: [WORD 2003] Opening Word from Outside Prog

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    46

    [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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    46

    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    46

    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()

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width