-
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
-
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:
Dim oWord As Word.Application
Dim oDoc As Word.Document
' This procedure demonstrates using the Execute
' method to replace text.
Set oWord = GetObject(, "Word.Application")
If oWord Is Nothing Then
Set oWord = CreateObject("Word.Application")
End If
oWord.Documents.Open FileName:="c:\test.doc"
oWord.Documents("test.doc").Activate
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.
-
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
-
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
-
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?
-
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
-
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.
-
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
-
Re: Creating Word Document
-
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.
-
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
-
Re: Creating Word Document
Quote:
Originally Posted by aicheema
what does user type not defined means. Nike
What line does this occur on?
-
1 Attachment(s)
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
-
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.
-
Re: Creating Word Document
Yes, It works .
Thanks alot
Nike
-
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.
-
1 Attachment(s)
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
-
Re: Creating Word Document
And you have the reference to the Microsoft Word Object Library in your project, right?
-
Re: Creating Word Document
-
Re: Creating Word Document
And, you have a document called c:\test.doc, right?
-
Re: Creating Word Document
-
Re: Creating Word Document
I will apprecaite ur reply back
Thanks
Nike
-
Re: Creating Word Document
Quote:
Originally Posted by aicheema
Yes, It worked once
Did you change anything after it worked?
-
Re: Creating Word Document
No, I juts tried to create it one more time
-
1 Attachment(s)
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.
-
Re: Creating Word Document
Hello,
Can I deploy this code on to web
Thanks
Nike
-
Re: Creating Word Document
Hello
Is there any way to deploy this program on the web
Thanks
Nike
-
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?