Results 1 to 3 of 3
  1. #1
    shiva
    Guest

    Word 2000 - objects (Word 2000)

    Hi all,

    I am new to VBA and I am trying to write data into a word 2000 document from a database, using VB6.0
    This is the code I have so far :

    Set objword = New Word.Application
    Set objdoc = objword.Documents.Add
    Set objdoc = ActiveDocument
    objdoc.ActiveWindow.Selection.InsertAfter "CLIENT : " & UCase(rs!client)
    objdoc.ActiveWindow.Selection.InsertParagraphAfter
    objdoc.ActiveWindow.Selection.InsertAfter "PROJECT NAME : " & rs!projname


    I need to be able to give different font formatting based on whether it is a cilent/projectname/....

    Can anyone help me in this or point me to good tutorials which explain the way to handle 'Range' and 'Selection' objects ?

    Thanks,
    Shiva.

  2. #2
    BAM
    Guest

    Re: Word 2000 - objects (Word 2000)

    Hi shiva,

    You might want to review this article by Microsoft Word MVP, Cindy Meister, on <A target="_blank" HREF=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnovba00/html/MailMergePartII.asp> Employing Word's Field and Formatting Capabilities </A>
    ~~~~~~~~~~~
    Cheers! <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Word 2000 - objects (Word 2000)

    I would code this a bit differently, just to reduce some of the overhead:

    Set objword = New Word.Application
    Set objdoc = objword.Documents.Add
    'Set objdoc = ActiveDocument 'not needed, objdoc already set above
    With objdoc.ActiveWindow.Selection
    .InsertAfter "CLIENT : " & UCase(rs!client)
    .InsertParagraphAfter
    If rs!projname = "Important Project" Then
    .Font.Bold = True 'turn on bold, for example
    End If
    .InsertAfter "PROJECT NAME : " & rs!projname

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •