hi all....can anyone tell me how to convert a textfile to word document using VB6....plz reply ASAP...i will be thankful...
Text file to Word document using VB6
Collapse
X
-
just change the extenstion,it'l l become a word document..
make sure to add Microsoft Scripting Runtime to ur project references,then add the following code..
Code:dim fso as filesystemobject private sub form_load() fso.copyfile("filepath\filename.txt","filepath\filename.doc") msgbox "saved successfully." end sub -
thanks a lot for ur reply....but my Visual Basic has a problem....ever ytime I click on the Project menu it says 'Visual Basic has encountered a problem and needs to close'......... .can u please give me another way to add 'Microsoft Scripting Runtime' to my project.......o nce again thanks for ur reply...
Originally posted by vdraceiljust change the extenstion,it'l l become a word document..
make sure to add Microsoft Scripting Runtime to ur project references,then add the following code..
Code:dim fso as filesystemobject private sub form_load() fso.copyfile("filepath\filename.txt","filepath\filename.doc") msgbox "saved successfully." end subComment
-
hi...i wrote the following function...
Code:(text)
1.Private Function Convert2word(tx tSourceFile As String) As String
2.Dim fso As FileSystemObjec t
3.fso.CopyFile txtSourceFile, "D:\filename.do c"
4.Convert2word = "D:\filename.do c"
5.End Function
But its hitting an error saying...Runtim e error '91' Object variable or with block variable not set....at the line 3 in the above code....what does it mean and can anyone help me out plz???...
Originally posted by vdraceiljust change the extenstion,it'l l become a word document..
make sure to add Microsoft Scripting Runtime to ur project references,then add the following code..
Code:dim fso as filesystemobject private sub form_load() fso.copyfile("filepath\filename.txt","filepath\filename.doc") msgbox "saved successfully." end subComment
-
Hi ravitunk,well that must be a problem of copyfile method of the filesystemobjec t..i too get an error for the same..i'll find out why and reply u back.Originally posted by ravitunkhi...i wrote the following function...
Code:(text)
1.Private Function Convert2word(tx tSourceFile As String) As String
2.Dim fso As FileSystemObjec t
3.fso.CopyFile txtSourceFile, "D:\filename.do c"
4.Convert2word = "D:\filename.do c"
5.End Function
But its hitting an error saying...Runtim e error '91' Object variable or with block variable not set....at the line 3 in the above code....what does it mean and can anyone help me out plz???...
why dont u try this(if u can add Microsoft Scripting Runtime to ur project references)..
try this(if u cant add that reference to ur project)..Code:Dim fso as filesystemobject dim f as file Private Sub Form_Load() Set f = fso.getfile("path\filename.txt") f.copy ("path\filename.doc") End Sub
Code:Dim fso as object Dim f as object Private Sub Form_Load() set fso = createobject("Scripting.FileSystemObject") set f = fso.getfile("path\filename.txt") f.copy ("path\filename.doc") End SubComment
-
thks a lot for ur reply....i tried the following code....and it worked....but when I goto the Word document and try to open it....it gives a prompt saying..."Micro soft Word can't import the specified format. This feature is currently not installed.Would you like to install it now?"......with Yes and No buttons.....wha ts this....if I click No then its opening the document with the contents.....pl ease tel me more abt that prompt...
Code:Dim fso as object Dim f as object Private Sub Form_Load() set fso = createobject("Scripting.FileSystemObject") set f = fso.getfile("path\filename.txt") f.copy ("path\filename.doc") End Sub
Originally posted by vdraceilHi ravitunk,well that must be a problem of copyfile method of the filesystemobjec t..i too get an error for the same..i'll find out why and reply u back.
why dont u try this(if u can add Microsoft Scripting Runtime to ur project references)..
try this(if u cant add that reference to ur project)..Code:Dim fso as filesystemobject dim f as file Private Sub Form_Load() Set f = fso.getfile("path\filename.txt") f.copy ("path\filename.doc") End Sub
Code:Dim fso as object Dim f as object Private Sub Form_Load() set fso = createobject("Scripting.FileSystemObject") set f = fso.getfile("path\filename.txt") f.copy ("path\filename.doc") End SubComment
-
I dont have such problem with the codehere ravitunk.eveyth ing is perfect here(I have MS Office 2007)..i dont know what the problem might be-will reply you once i find out..Originally posted by ravitunkthks a lot for ur reply....i tried the following code....and it worked....but when I goto the Word document and try to open it....it gives a prompt saying..."Micro soft Word can't import the specified format. This feature is currently not installed.Would you like to install it now?"......with Yes and No buttons.....wha ts this....if I click No then its opening the document with the contents.....pl ease tel me more abt that prompt...
Code:Dim fso as object Dim f as object Private Sub Form_Load() set fso = createobject("Scripting.FileSystemObject") set f = fso.getfile("path\filename.txt") f.copy ("path\filename.doc") End SubComment
-
ohh ok...thks for ur replies and help.....actual ly my task is to copy the textfile content to an exiting pdf file which has a header and a footer....plz revert back if u know this.....or
to accomplish the same task am planning to convert the txtfile to a template word document(which has header and footer)...and then want to convert tht to pdf file....
.............an yone of the above two approaches will be fine......plz reply back soon.....thks for ur help once again....
Originally posted by vdraceilI dont have such problem with the codehere ravitunk.eveyth ing is perfect here(I have MS Office 2007)..i dont know what the problem might be-will reply you once i find out..Comment
Comment