VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Demonstrates how to save your text as a word file, and launch MS Word in Visual Basic with your typ

by Kwame (1 Submission)
Category: OLE/COM/DCOM/Active-X
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 26th July 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Demonstrates how to save your text as a word file, and launch MS Word in Visual Basic with your typed text.

API Declarations


Dim msWord As Word.Application


Rate Demonstrates how to save your text as a word file, and launch MS Word in Visual Basic with your typ



'Note: place a command button on your form and name it cmdWrite.
'      place a textbox on the form, set the multline to true if you want
'      reference Microsoft Word 8.0 Object Library
'      goto view code mode, copy the code, and paste it there and press f5.
'      enjoy

Private Sub Form_Initialize()
   Set msWord = New Word.Application
End Sub

Private Sub cmdWrite_Click()
   cmdWrite.Enabled = False
   Call msWord.Documents.Add
   msWord.Selection.Shading.Texture = wdTexture22Pt5Percent
   msWord.Selection.Font.Size = 15
   msWord.Selection.Font.Bold = True
   msWord.Selection.Font.Italic = True
   Call msWord.Selection.TypeText(Text1.Text)
   Call msWord.Documents(1).SaveAs("c:\kwame.doc")
   msWord.Visible = True
  ' Call msWord.Quit 'uncomment if you don't want launch ms word

End Sub

Private Sub Class_Terminate()
   Set msWord = Nothing
End Sub


Download this snippet    Add to My Saved Code

Demonstrates how to save your text as a word file, and launch MS Word in Visual Basic with your typ Comments

No comments have been posted about Demonstrates how to save your text as a word file, and launch MS Word in Visual Basic with your typ. Why not be the first to post a comment about Demonstrates how to save your text as a word file, and launch MS Word in Visual Basic with your typ.

Post your comment

Subject:
Message:
0/1000 characters