Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Vb to MS word

Posted on 2004-09-23
2
Medium Priority
?
187 Views
Last Modified: 2010-05-02
Hi:

My problems is:in a vb application,i want to code when user click to a button it will create a MS word(.doc) file to fill some data(text)and image into this word file.So how to do that?

 At the same time,i wish can adjust some properties  for that word doc in vb coding when that user click to that print button(for example adjust the margin of that word doc.....)


Thanks...
0
Comment
Question by:qfren
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
avi247 earned 500 total points
ID: 12139954
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oPara1 As Word.Paragraph
Dim oPara2 As Word.Paragraph
' Application type
Set oWord = New Word.Application
oWord.Visible = True
'objWord.Documents.Open "C:\word.doc"
Set oDoc = oWord.Documents.Add
' set page setup, margins here
With oWord.Selection.PageSetup
    .Orientation = wdOrientPortrait
    .TopMargin = InchesToPoints(1)
    .BottomMargin = InchesToPoints(1.5)
    .LeftMargin = InchesToPoints(1.5)
    .RightMargin = InchesToPoints(1)
    .Gutter = InchesToPoints(0.25)
End With

' add text
Set oPara1 = oDoc.Content.Paragraphs.Add
With oPara1.Range
    .Text = "Experts Exchange"
    .Font.Size = 12
    .Font.Bold = True
    .InsertParagraphAfter
End With

Set oPara2 = oDoc.Content.Paragraphs.Add
oPara2.Range.Text = "Visual Basic"

' add an image
oWord.Selection.InlineShapes.AddPicture "C:\envelope.gif", False, True

oDoc.SaveAs ("C:\expert1.doc")
oDoc.Close
oWord.Quit
Set oPara1 = Nothing
Set oPara2 = Nothing
Set oDoc = Nothing
Set oWord = Nothing
0
 
LVL 8

Author Comment

by:qfren
ID: 12156861
Thanksl for reply...
GIve me sometime to apply it and i will back here...



mc
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question