• Inserting Clipart Etc. (Word97(SR2))

    Author
    Topic
    #361360

    Does anyone know of a way to insert more than one graphic at a time?

    Better yet, in the good old days when I was using WordPerfect for DOS, I had a macro that would allow me to specify a directory, then create a blank document with a thumbnail of each graphic (and the graphic’s filename) from that directory. Anybody know of anything similar I can use in Word?

    Thanks!

    Viewing 0 reply threads
    Author
    Replies
    • #546119
      • #546145

        Hi,

        You might like to try this one which works in W97:

        Public Sub MAIN()
        Dim i
        Dim file$
        Dim j
        'Creates a Document of Clipart (or bmps) from the Current Directory
        'For bmps change the line that says *.wmf
        ' Dimension an array to hold the filenames of the images.
        ReDim f__$(200)
        ' Insert a three column table to provide a columnar place to
        ' display the images.
        WordBasic.TableInsertTable ConvertFrom:="", NumColumns:="3", _
        InitialColWidth:="Auto", Format:="16", Apply:="167"
        WordBasic.TableRowHeight AllowRowSplit:=0
        'TableInsertTable .NumColumns = "3"
        ' Loop through all the filenames that meet the specified
        ' image type using the Files$() function from WordBasic.
        i = 0
        file$ = WordBasic.[Files$]("*.wmf")
        'file$ = Files$("*.bmp")
        f__$(i) = file$
        While file$  ""
          file$ = WordBasic.[Files$]()
          i = i + 1
          f__$(i) = file$
        Wend
        ' Now that the filenames are stored in an array, loop
        ' through the array and bring in the images.
        For j = 0 To i - 1
        ' First insert the filename and a paragraph mark.
          WordBasic.Insert f__$(j)
          WordBasic.InsertPara
        ' Now insert the picture and some paragraph marks.
          '  Selection.InlineShapes.AddPicture (f__$(j), _
                LinkToFile:=False, SaveWithDocument:=True)
          WordBasic.InsertPicture f__$(j)
          WordBasic.CharLeft 1, 1
          WordBasic.CharRight
          WordBasic.InsertPara
        ' Use the NextCell command to generate a new row in the table.
          WordBasic.NextCell
        Next j
        End Sub
        

        Good Luck!

        • #546166

          Peter,
          Thank you! That looks like it will do the trick. I really appreciate your help (jscher2000’s, too). You guys have saved me from reinventing an old wheel.

        • #546187

          Jscher/Peter, I too used to use the macro that was available in WordPerfect to produce an index sheet of the contents of a graphics directory (which was available for many of the Windows versions as well as the DOS one) and would love to have something similar in Word.

          However, when I tried your macro it just produced six cell table with nothing in it! I’m sure I’m just being stupid, but where am I going wrong?!

          • #546284

            Beryl,

            Sorry you had problems with the macro, but I do have one admission that may help – to get it on the board I had to insert a continuation in the line “Wordbasic.TableInsertTable…” so Iwould suggest that you remove the underscore on that line and combine the line with the next line. Otherwise check that you have it line for line and that you do not have any lines split.

            Hope this helps!

            • #546345

              Peter

              Thanks for your response, but I had noticed the underscore, and it wasn’t that line that’s causing the problem, as far as I can tell. I copied your code en masse, via Word, into VBA direct, so it can’t be a typing error (which in any case would cause a debug error, surely?).

              The impression I get is that it’s running fine, but not finding any graphics to insert – so how do you tell it which directory to look in? I can’t see which line it is that does this …!

            • #546543

              This is not suitable for distribution, but as a quickie way to browse around for the right path, how about this:

              Dim strPicturePath As String
              With Dialogs(wdDialogInsertPicture)
                  If .Display = 0 Then Exit Sub
                  strPicturePath = .Path
              End With
              strPicturePath = Trim(InputBox("Edit this to the desired filespec (e.g., " & _
                                  "c:photos*.jpg)", , strPicturePath))

              strPicturePath would then replace “*.wmf” in the Files$ command.

              If you want to build something more usable, look into the FileSearch object. I think it understands the concept of graphics files and could provide a more flexible solution.

            • #546727

              Beryl,

              I hope you had some success with Jefferson’s suggestion.

              I have not found this a problem as I would usually go into the directory first using Word’s FileOpen dialog box and with “Files of Type:” set as “All Files (*.*)” to see if there were *wmf files there before I ran the macro, and once you go into a directory it becomes the current directory, so the macro can then be run.

              Hope this Helps!

            • #546810

              The macro seems to run fine, but I can’t see the pictures. Mine are jpg, and I changed the file type to jpg in the code. I see the placeholders for the code. I checked to be sure Word would view a jpg by inserting one manually, and it viewed fine. What am I missing? If this works, this could be a lifesaver for one of our users. She has been asking for this for quite sometime now.

            • #546895

              Melanie,

              Sorry this is not working exactly the way you would like, but I think I understand your problem as I have just sucessfully done what you wanted.

              I replaced the line with “*.wmf” with one with ‘*.jpg”, which is I suspect exactly what you did.

              When the macro runs it looks only at the Current Directory, which is set when you do File Open and go the the directory you want to use to create the document (NB: not when you goto Insert Picture).

              After making the above change to test your situation this is what I did to test that it worked for jpg’s:

              1. In Word I used File Open to navigate to the directory where the jpg’s reside. When I found the directory I selected Cancel – this has set the Current Directory to the directory the macro will use.

              2. I then just ran the macro and WOW! all the jpg’s came up beautifully, three across the page. (Actually I had never used this macro on jpg’s before, and really think it’s great. By the way I did not write the macro but picked it up for Clipart from Microsoft about 5 years ago!!)

              I hope you can achieve the same result!

              Good Luck!

            • #546899

              I did exactly what you are talking about. The macro seems to run fine. It creates the tables, and the text, and even creates the squares for the pictures. But, the pictures don’t display. I have checked the Options to be sure Word is set to display graphics, and it is. Could this be because I am opening files from across a network? I don’t see how. The text/description for each jpg is correct. This is sooooo close! I just know I’m only missing one tiny thing that will let me view the jpgs.

              I have tried double-clicking or right clicking on the image borders and selecting Edit Picture, but when I do, nothing happens. The option is there when I right-click, so I know it thinks it’s a picture.

              If I manually insert the picture, using the same path as the macro puts in each cell, the picture inserts fine and I can view the jpg.

            • #546912

              Melanie,

              This is getting out of my depth!

              I have checked the Microsoft Knowledge Base and the following article is there:

              WD97: Clipart Images Display Incorrect Format Picture Options (Q173286)

              http://support.microsoft.com/support/kb/ar…N-AU&SD=gn&FR=0

              It suggests that this is a known problem and the solution is to save as a HTML file and then re-open.

              I can only suggest you check your options in Tools Options View etc., otherwise it may be an incompatibility between WordBasic and the version of Word you are using.

              I am sorry I can’t be of more help.

            • #547035

              Thanks anyway. I’ve been playing with this, and there is something about how the directory is named that affects it. I haven’t pinned it down exactly. But, I think if there are underscores in the directory name, the picture won’t display. I managed to get two directories to display the pictures. The common thread was that the filenames and directory name were fairly short and didn’t contain any characters. I’m not 100% sure this is right, but at least I got SOMETHING to display. I’ll post the answer when I’m done so that it might help someone else with this.

              In the meantime, if anyone knows how the file name or directory name affects this code, please let me know. I know absolutely nothing about VB, and I can’t really figure this out any other way than just trial and error.

            • #547122

              Well, it is the file name or folder name. If there are any spaces or odd characters in the file name or folder name, the picture won’t print. Not a problem on my end, I just renamed things and it works great.

              Thanks!

            • #547133

              Melanie,

              I have just tried changing my directory from “Pictures” to “Pictures_nat_geog” and everything continued to work fine.

              However your last note about SPACES in file or directory names is a very different matter, and I have just verified that using “Pictures Nat Geog” will list the table and file names but not the pictures – as you previously found.

              Given that spaces were once not permitted in directory or file names, there will continue to be vestiges of this situation around, especially when you don’t want it!! a bit like Murphy’s law – if anything can go wrong it will, and at the most inopportune moment!

              I may be able to have a look at it if I get time, and will re-post if I do come up with a solution.

              Regards

      • #546165

        Thanks, Jefferson! As you can see in the post following yours, Peter Moran seems to have expanded on the filename routine. Between the two of you, I’m on the road.

    Viewing 0 reply threads
    Reply To: Inserting Clipart Etc. (Word97(SR2))

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

    Your information: