• Adding bmps into a table (2003)

    Author
    Topic
    #425556

    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

    Viewing 0 reply threads
    Author
    Replies
    • #980727

      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.

      • #980729

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

        • #980730

          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…)

    Viewing 0 reply threads
    Reply To: Adding bmps into a table (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: