Results 1 to 3 of 3

Thread: integrating MS-Word

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2005
    Posts
    35

    integrating MS-Word

    Hi,
    I know that it's easy to do but I never try to do it:
    I have a letter (using ms word) where I am not enering the customer name, but I need to know how can I be able to print this letter from VB for each customer the user choose to send this letter to.
    How can I be able to do so?
    note: a sample will be helpfull...

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: integrating MS-Word

    you can set a bookmark for your cutomername
    assuming your list of customers is in an array
    vb Code:
    1. Dim d As Document, b As Bookmark
    2. Set d = documents("my letter")
    3. Set b = d.Bookmarks("customername")
    4. b.Range.Text = customerarr(0)
    5. d.printout
    6. for i = 1 to ubound(customerarr)
    7.    b.Range.Find.Execute customerarr(i-1), , , , , , , , , customerarr(i), wdReplaceOne
    8.    d.printout
    9. next
    Last edited by westconn1; Nov 10th, 2007 at 07:05 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: integrating MS-Word

    Or you can create a MailMerge.

    http://vbforums.com/showthread.php?t=402097
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width