Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding bmps into a table (2003)

    I have about 10,000 .bmps (barcodes) that I would like to insert into a table (20 down, 4 across). Can I do a mail merge? The .bmps are saved as seperate images on our server. I am currently dragging and dropping them into the table

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding bmps into a table (2003)

    Mail merge would only work if you already have a table with all the file names.

    If all .bmp files are in a single folder and if there are no other .bmp files in that folder, you could write a macro that loops through the files in the folder, and adds them to the table one by one. Post back if you need help with this.

  3. #3
    New Lounger
    Join Date
    Sep 2005
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding bmps into a table (2003)

    Within the folder is the 10,000 .bmps files. Attached is what it looks like. Can you help me with the macro, if applicable?
    Attached Images Attached Images

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Adding bmps into a table (2003)

    Try the following on a copy of your document. I don't know if Word will accept 10,000 images.

    - Activate the Visual Basic Editor (Alt+F11).
    - Insert a module (Insert | Module or Alt+I, M)
    - Paste the following code into the module:

    Sub InsertPics()
    ' Modify as needed, but keep trailing backslash
    Const strPath = "C:MyPictures"
    Dim strFile As String

    On Error GoTo ErrHandler
    Application.ScreenUpdating = False

    ActiveDocument.Tables(1).Cell(1, 1).Select

    strFile = Dir(strPath & "*.bmp")
    Do
    Selection.InlineShapes.AddPicture _
    FileName:=strPath & strFile, _
    LinkToFile:=False, _
    SaveWithDocument:=True
    strFile = Dir
    If strFile = "" Then Exit Do
    Selection.MoveRight Unit:=wdCell
    Loop

    ExitHandler:
    Application.ScreenUpdating = True
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

    - Substitute the correct path to the pictures in the strPath constant. Make sure to keep the at the end.
    - Save (the copy of) the document now.
    - Run the macro, either by clicking in it in the Visual Basic Editor and pressing F5, or from Word (Tools | Macro | Macros...)

Posting Permissions

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