Results 1 to 13 of 13

Thread: [RESOLVED] word to vb

  1. #1

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Resolved [RESOLVED] word to vb

    isit possible that we insert ms word to our vb program?

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

    Re: word to vb

    You mean like display a Word document contents in your app or the actual Word application app in your app?
    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

  3. #3
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: word to vb

    to just insert the OLE control from the toolbox and select create new and select word document. I hope this is what you want
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  4. #4

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: word to vb

    What if I want to make a link on my VB application so that when I click it, Microsoft Word program will open and show my words document. Is that possible?

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

    Re: word to vb

    Do you wish to create a new, blank, Word document, or open and display an existing Word document?

  6. #6

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: word to vb

    open and display an existing word document

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

    Re: word to vb

    Set a reference to the Microsoft Word Object Library
    Code:
    Private Sub Command2_Click()
    'to open an existing word document
    Dim objWord As Word.Application
    Set objWord = CreateObject("Word.Application")
    objWord.Documents.Open ("c:\worddocs\yanty.doc")
    objWord.Visible = True
    End Sub

  8. #8

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: word to vb

    it states user-defined type not defined and points to line
    Dim objWord As Word.Application

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

    Re: word to vb

    Quote Originally Posted by yanty
    it states user-defined type not defined and points to line
    Dim objWord As Word.Application
    This is because you haven't done this
    Quote Originally Posted by Hack
    Set a reference to the Microsoft Word Object Library

  10. #10

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: word to vb

    Yay! It worked. Yeah.. I forgot the reference. Thank you.

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

    Re: word to vb

    Quote Originally Posted by yanty
    Yay! It worked. Yeah.. I forgot the reference. Thank you.
    You are welcome. In the event you (or someone else reading this) may some day have a need to open a new, blank, Word document, I'll post this
    Code:
    Private Sub Command1_Click()
    'to open a new, blank, word document
    Dim objWord As Word.Application
    Set objWord = New Word.Application
    objWord.Visible = True
    objWord.Documents.Add
    End Sub
    Dont forget the reference to the Word Object Library.

  12. #12

    Thread Starter
    Lively Member yanty's Avatar
    Join Date
    Nov 2005
    Location
    Singapore
    Posts
    83

    Re: [RESOLVED] word to vb

    But if I were to move my VB application to another folder, I would have to change the location of the file. How can I make my file stick to my VB application. Meaning i dun have to change from c:\desktop\form1.doc to i:\form1.doc everytime i run the program.

    i tried to type objWord.Documents.Open ("\form1.doc") only but error occurs cos I need to specify the exact location the file is in.

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

    Re: [RESOLVED] word to vb

    Use App.Path

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