CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Location
    Melbourne
    Posts
    27

    Access an object in Word from VB

    Hi all,

    I have created a Word XP document, and in to that document I have inserted 16 barcode objects. They have all the usual properties as seen in Visual Basic.

    How do I access the Barcode objects in the Word document via Visual Basic?

    I am using VB to:-

    Ask the user how many barcode labels are to be printed
    Retrieve the next xx barcode numbers from the Access DB
    Pump the barcode number in to a bookmark for easy reading
    Print the associated barcode beneath the number

    All the above works except for the last line.

    How do I update the BarCode number property of the Barcode objects? The barcode objects are placed correctly and are called (for want of a more descriptive name) - "Barcode1 ~ Barcode16".

    Thanks

    Mark

    (Now don't say I could do all the above using VBA. I like VB!)

  2. #2
    Join Date
    Aug 2001
    Posts
    1,447
    question is totally unclear

    perhaps you are trying to form a construct such as:

    myName$ = "Barcode" & Cstr(thisNumber)
    phinds
    vs2008, 3.5SP1 Version 9.0.21022.8 RTM

  3. #3
    Join Date
    Mar 2003
    Location
    Melbourne
    Posts
    27
    Ahhh, perhaps my question was unclear. (I have figured it out...)

    Start Word.

    New blank document.

    Insert... Object...

    I added a control called "Barcode".

    Back in VB I added the following code:-

    objWord.Documents.Open ("my.doc")
    Set objDoc = objWord.ActiveDocument
    objWord.Visible = False

    Now one of the things I needed to do was feed in a new barcode number in to the "Barcode.text" property of the barcode control in the Word document.

    I was trying all sorts of bizarre commands to add that text, but finally figured out that it was as simple as:-

    objDoc.barcode.Text = "1234567890"

    Thanks for your reply!

    I'm slowly figuring this out!

    Mark

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

Featured