Does ANybody have a copy of some code I can use to hook to my app to a Document in Word??? So to open Word from VB. I also want to paste some fields from a DB into the Word document so any samples to look at of that would be excellant to! Thanks.
Printable View
Does ANybody have a copy of some code I can use to hook to my app to a Document in Word??? So to open Word from VB. I also want to paste some fields from a DB into the Word document so any samples to look at of that would be excellant to! Thanks.
This is something I posted a few weeks ago.
I got this off of MSDN:
http://msdn.microsoft.com/vbasic/technical/pasttips.asp
For the Week of April 26th
Creating Professional Documents with Code
Have you ever wanted to create polished, professional documents, like those created in Microsoft Word, through the use of code? Follow these easy steps to make it happen:
First add a reference to your project for "Microsoft Word 8.0 Object Library" (MSWORD8.OLB).
Then add the following code to create an instance of Word and add text to a new document:
Dim objWord As New Word.Application
'-- Show Microsoft Word
objWord.Visible = True
'-- Add new Document
objWord.Documents.Add
'-- Add text to Document
objWord.Selection.TypeText "Visual Basic!"
'-- Select all Text
objWord.Selection.WholeStory
'-- Change Font Size
objWord.Selection.Font.Size = 50
Set objWord = Nothing
Check out the Object Browser for more properties and methods exposed by the Word Object.
--------------------------------------------------------------------------------
Does Anybody know have any code that will open a document that already exists??? Then Paste info in.