Results 1 to 28 of 28

Thread: Creating Word Document

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Creating Word Document

    Hello

    I want to create a word document that can be editable . Also I want to add some text to word document from database. Please let me know the useful link for this. Also if there is any free editor and compiler for VB to download.

    Thanks in advance
    Nike

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

    Re: Creating Word Document

    Quote Originally Posted by aicheema
    Hello

    I want to create a word document that can be editable . Also I want to add some text to word document from database. Please let me know the useful link for this. Also if there is any free editor and compiler for VB to download.

    Thanks in advance
    Nike
    Welcome to the forums.

    To open a word document, set a reference to the Microsoft Word Object Library. Then use something like
    VB Code:
    1. Dim oWord As Word.Application
    2.     Dim oDoc As Word.Document
    3.    
    4. ' This procedure demonstrates using the Execute
    5. ' method to replace text.
    6.  
    7.     Set oWord = GetObject(, "Word.Application")
    8.     If oWord Is Nothing Then
    9.         Set oWord = CreateObject("Word.Application")
    10.     End If
    11.    
    12.     oWord.Documents.Open FileName:="c:\test.doc"
    13.     oWord.Documents("test.doc").Activate
    14.    
    15.     Set oDoc = oWord.ActiveDocument
    .frm forms are fundamentally text files, so you can actually open them with Notepad. There is only one VB6 compiler, and it comes with VB6, and is not free.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Hello,

    Thanks for help. Actually I am coldfusion programmer But I have to create a rtf document that is supported by VB. If you can send me link or describe me how can I use the editor to run this code .

    Thanks in advance.

    Nike

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Hello,

    Thanks for help. Actually I am coldfusion programmer But I have to create a rtf document that is supported by VB. If you can send me link or describe me how can I use the editor to run this code . I am using Microsoft VB6.0

    Thanks in advance.

    Nike

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

    Re: Creating Word Document

    Quote Originally Posted by aicheema
    Hello,

    Thanks for help. Actually I am coldfusion programmer But I have to create a rtf document that is supported by VB. If you can send me link or describe me how can I use the editor to run this code . I am using Microsoft VB6.0

    Thanks in advance.

    Nike
    Use what editor?

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    I am using Microsoft Visual studio and version is Visual Basic 6.0 . Actually when I open the IDE there were alot of options. I was not sure which one I have to pick.

    Thanks
    Nike

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

    Re: Creating Word Document

    Quote Originally Posted by aicheema
    I am using Microsoft Visual studio and version is Visual Basic 6.0 . Actually when I open the IDE there were alot of options. I was not sure which one I have to pick.

    Thanks
    Nike
    Ok, gotcha.

    Step 1. Click Project/References

    Find Microsoft Word Object Library

    Click the checkbox next to it.

    Click OK.

    Now you have the proper reference to use Word in your VB program.

    The code to open a Word document that I orginally posted should work now.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Thanks
    Do I have to create New Project, If yes, Which one I have to choose (DHTML Application,VB Wizard Manager etc)

    Thanks
    Nike

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Thanks I got it

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

    Re: Creating Word Document

    Quote Originally Posted by aicheema
    Thanks I got it
    Ok good. If you have any more questions, especially after you get your document opened, post back.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    what does user type not defined means. if you dnt mind do u have any contact numebr. I will give u call at your suitable time to get the things set to go.
    Thanks
    Nike

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

    Re: Creating Word Document

    Quote Originally Posted by aicheema
    what does user type not defined means. Nike
    What line does this occur on?

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Set oWord = GetObject(, "Word.Application")

    It says Compiler Error. Invalied Outside Procedure. Also I created a New Project Standard EXE and clicked the code and insert your code into form opened and then I run it .

    Please also look at the screen view in attachment
    Attached Files Attached Files

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

    Re: Creating Word Document

    Move all of the code from where you have it and put it in the click event of a command button.

  15. #15

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Yes, It works .

    Thanks alot
    Nike

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

    Re: Creating Word Document

    The code window that you opened up is the General Declarations section of the form.

    Variables that will be used through the form are declared there. API declarations for calls that will be used through the form are declared there. But, event driven code, like what you are using to open your word document, must be used in a control's click event, or in a sub or function that is called by the controls click event.

  17. #17

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Hello

    It is again giving me error. Run time error 429: Activex Cannot create object.

    Please see the screem view in attachment.

    Thanks in advance
    Nike
    Attached Files Attached Files

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

    Re: Creating Word Document

    And you have the reference to the Microsoft Word Object Library in your project, right?

  19. #19

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Yes, I do

    Nike

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

    Re: Creating Word Document

    And, you have a document called c:\test.doc, right?

  21. #21

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Yes, It worked once

  22. #22

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    I will apprecaite ur reply back

    Thanks
    Nike

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

    Re: Creating Word Document

    Quote Originally Posted by aicheema
    Yes, It worked once
    Did you change anything after it worked?

  24. #24

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    No, I juts tried to create it one more time

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

    Re: Creating Word Document

    Attached is an example. It works just fine. All you have to do is change the name and location of the word document.
    Attached Files Attached Files

  26. #26

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Hello,

    Can I deploy this code on to web

    Thanks
    Nike

  27. #27

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    Re: Creating Word Document

    Hello

    Is there any way to deploy this program on the web

    Thanks
    Nike

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

    Re: Creating Word Document

    Quote Originally Posted by aicheema
    Hello

    Is there any way to deploy this program on the web

    Thanks
    Nike
    That sample code is for VB. I think you can translate it into VBScript, but I'm not sure. Also, in order for it to work, the user has to have Word installed locally. Can you be sure that all people visiting your web page will have Word installed on their PC?

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