DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Bassel Tabbah Guest

    How to Paste selection to word


    In VBA, how can I copy and paste selected items in listbox to my acitve document
    in Word 97. Thank you for your help.

  2. #2
    Duane Guest

    Re: How to Paste selection to word


    "Bassel Tabbah" <tabbah@un.org> wrote:
    >
    >In VBA, how can I copy and paste selected items in listbox to my acitve

    document
    >in Word 97. Thank you for your help.



    I am currently working on a project that does this ( transferres an outlook
    contact to word template). You will
    need to add a reference to the Word 97 object lib.

    I have copied some of the code here. Hope it helps you.

    Duane Snelling dsnelling@msc.ca

    '''''''''''''''
    'This open and edits a document template
    ''''''''''
    Set sWord = CreateObject("Word.Application")
    sWord.Documents.Open sLocation
    ''''''''''''''''''''
    ''''''''''''''''''''
    'Searches through a word document for {\NAME} and inserts to contact name
    everytime found.
    ''''''''''''''''''''
    With Word.ActiveDocument.Content.Find
    .ClearFormatting
    'search name
    Do While .Execute(FindText:="{\NAME", Forward:=True, _
    Format:=True) = True
    With .Parent
    .Delete
    .InsertAfter " " & sContact
    .Move Unit:=wdParagraph, Count:=200
    End With
    Loop
    End With
    ''''''''''''''''''''''''
    'Quit the winword to free resourses
    sWord.Quit SaveChanges:=wdSaveChanges, OriginalFormat:=wdWordDocument


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links