Results 1 to 5 of 5

Thread: opening a word document in vb.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    2

    opening a word document in vb.net

    I have 2 problems.

    - I have a form and a button.I want to open a word document every time i click on this button.
    What do I have to write?

    -I want to move a cursor in a textbox located in a form. How can I use Windows API?

  2. #2
    Lively Member markmyb's Avatar
    Join Date
    Nov 2001
    Location
    Alberton - South Africa
    Posts
    108
    can help you with the word section:

    add a reference to word..
    projects --> add reference --> com tab

    in code:
    Dim oWord As New Word.Application

    'application
    oWord.Documents.Open(Application.StartupPath & "\china.doc")
    oWord.WindowState = Word.WdWindowState.wdWindowStateMaximize
    oWord.Visible = True


    when you close the app make sure to
    run this code as well or else your'll get 100 winword.exe's running in memory.

    oWord.Documents.Close()
    oWord.Quit()
    oWord = Nothing
    Confusios say "Man who run in front of car get tired."

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    2
    Hello!

    It doesn't work because I have no reference to word.

    Do you have another idea?

    Thank you for understanding.

  4. #4
    Lively Member
    Join Date
    Aug 2003
    Location
    When?!?!
    Posts
    108

    A suggestion to your problem

    Originally posted by sandrino
    Hello!

    It doesn't work because I have no reference to word.

    Do you have another idea?

    Thank you for understanding.
    Try begging one of your programmer friends to share the main DLL with you.
    DannyJoumaa
    Advanced VB6 Programmer
    Intermediate-Advanced VB .NET Programmer
    Intermediate C# Programmer
    Intermediate Win32 Developer
    Beginner Mac OS X Developer
    Contact: [email protected]

    Favorite Sayings:
    "Every time you open your mouth, you prove your an idiot."
    "God is a programmer. Satan is a bug. Life is debugging."

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    This will open the doc file with whatever application is associated with that extension.
    VB Code:
    1. Process.Start(Application.StartupPath & "\china.doc")

    If it gives you trouble then Process is in the System.Diagnostic namespace.

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