I created one word document by using 'open "file.doc" for output as #1'. I also want to format the contents of word by using VB coding (examle : Bold,size....), but I don't know how to do it . pls help me on this issue.
Re: word format in 'open "file.doc" for output as #1'
I am not an expert with anything of this type, but I am pretty sure the word documents use encryption and things inside their files. Save a word document and vew it in notepad, and see what I mean. Writing to .doc files is very hard. You could try writing to an RTF file, but I'm not sure if that would work either because of the quotes VB puts around everything when it writes to files.
Hope this helps.
-X3ndou
31-08-2004 at 09:36 PM
|
BRMC Level: VB Lord Registered: 28-11-2003 Posts: 210
Re: word format in 'open "file.doc" for output as #1'
Hi,
u can use by setting in your references to Microsoft Word
or by :
Dim WApp as Object
Set WApp = CreateObject("Word.Application")
WApp.Visible = True
then u can work in vb on your document for example:
Private Sub Command1_Click()
Dim oWord As Object
Dim oTmpDoc As Object
Dim lOrigTop As Long
' Create a Word document object...
Set oWord = CreateObject("Word.Application")
Set oTmpDoc = oWord.Documents.Add
oWord.Visible = True
' Position Word off screen to avoid having document visible...
lOrigTop = oWord.Top
oWord.WindowState = 0
oWord.Top = -3000
' copy the contents of the text box to the clipboard
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Clipboard.Clear
Clipboard.SetText Text1.SelText
' Assign the text to the document and check spelling...
With oTmpDoc
.Content.Paste
.Activate
.CheckSpelling
' After user has made changes, use the clipboard to
' transfer the contents back to the text box
.Content.Copy
Text1.Text = Clipboard.GetText(vbCFText)
' Close the document and exit Word...
.Saved = True
.Close
End With
Set oTmpDoc = Nothing
oWord.Top = lOrigTop
oWord.Quit
Set oWord = Nothing
End Sub
____________________________
I don't mind not going to heaven
As long as they've got cigarettes
in hell