Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving as a GIF (VBA Word 2000)

    Is there a way to create a macro that will select a block of text and save as a .gif?

    I need to take a list of words or phrases, say in a table or just one word/phrase per paragraph, and save each one as a .gif file. Is there a way to do this with VBA?

    Thanks!!
    Troy

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Saving as a GIF (VBA Word 2000)

    Hi Troy,

    (I always respond to posts that feature my initials!)
    Hate to go against the 'never say die' grain here, but this sounds virtually impossible to do via VBA. When you select text in the text layer, what is being selected is basically a text string (with whatever formatting may be linked to it), rather than a picture of something that can be saved to a graphics format.

    Neither does any office app allow you save a file as a .gif (that I know of) - so you can't create a new file containing just the selected text and save as .gif.

    You may need to find a different way to get done what you need to do....

    Gary

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Saving as a GIF (VBA Word 2000)

    I could imagine, but not code, the following:

    (1) Determine the screen coordinates of the selection.
    (2) Using something in the Windows API, capture that portion of the screen.
    (3) Run some graphical toolkit to change from whatever the native format is to GIF.

    While it is tempting to think about a print screen, SendKeys cannot access the PrintScreen button, so the usual shortcuts don't appear to be available.

    Also, all the colors would be backwards if the text was selected. Hmmm...

    There probably is some software out there, akin to WordArt, that can save as GIF, but whether it can be automated...

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving as a GIF (VBA Word 2000)

    One way is to select the text and the Print the selection as a PDF file.

    You can then open the PDF file in Acrobat and save it as, say, JPG or PNG.

    Then use some drawing tool such as Photo Editor to save as GIF.

  5. #5
    4 Star Lounger
    Join Date
    Apr 2001
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving as a GIF (VBA Word 2000)

    What version of Acrobat allows that? I have Acrobat 4.05 and cannot find the capability to save as a jpg.

    Also, can it do that as a batch job? If so, I think I'd be home free. I could automate saving the selection as a pdf, batch the pdfs to jpg, and then use Paintshop Pro to batch the jpgs to gifs.

    Thanks for your help!!
    Troy

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving as a GIF (VBA Word 2000)

    The File | Save As menu in Acrobat 5 allows saving as eps, jpg, png, rtf, tif, txt, ps, eps.

  7. #7
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving as a GIF (VBA Word 2000)

    Howard,
    I suppose you mean the full version of Adobe Acrobat.
    The reader only don't have this options.
    Francois

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving as a GIF (VBA Word 2000)

    Oui!

  9. #9
    Lounger
    Join Date
    Jan 2001
    Location
    Kingwood, Texas, USA
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving as a GIF (VBA Word 2000)

    PowerPoint (I checked this in 2002) allows you to Save As a .gif.

  10. #10
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Working Code

    Hi Margot,

    Thanks very much for straightening me out on this - I'd never bothered to look - but you can save PPTs as .gifs, .jpgs, .wmfs and a bunch of other nice things. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

    Best of all, this means that Troy's request actually is doable; I'm happy to contradict my original reply 'cause this is a sweet little macro: <img src=/S/groovin.gif border=0 alt=groovin width=21 height=21>

    <pre>Public Sub SaveWordPhraseAsGIFViaPPT()
    'Gary Frieder Woody's Lounge March 2002
    'Purpose: For each paragraph in a Word document,
    'saves the text as a GIF (via PowerPoint)
    'Assumes a reference has been set to PPT library
    Dim DocParas As Paragraphs
    Dim strPhrase As String
    Dim n As Long
    Dim PPT As PowerPoint.Application
    Dim TempPres As PowerPoint.Presentation
    Dim TempSlide As PowerPoint.Slide
    Set PPT = New PowerPoint.Application

    Set DocParas = ActiveDocument.Paragraphs
    For n = 1 To DocParas.Count
    strPhrase = DocParas(n).Range.Text
    Set TempPres = PPT.Presentations.Add
    Set TempSlide = TempPres.Slides.Add(1, ppLayoutText)
    TempSlide.Shapes(2).Delete
    TempSlide.Shapes(1).TextFrame.TextRange.Text = strPhrase
    TempPres.Export "C:TempWord Phrase #" & n, "GIF"
    TempPres.Close
    Next 'n

    PPT.Quit

    Set DocParas = Nothing
    Set TempPres = Nothing
    Set TempSlide = Nothing
    Set PPT = Nothing

    End Sub
    </pre>

    Thanks again,
    Gary

  11. #11
    Lounger
    Join Date
    Jan 2001
    Location
    Kingwood, Texas, USA
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working Code

    I do like that macro. I may never *need* it, but I made a copy of it just in case!!! Ran just fine. Plus it may come in handy as a "go-by" if I ever want to open PowerPoint from Word.

  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working Code

    >this is a sweet little macro:
    I might say that.
    It's sweeter still as a little function that harvests inline shapes from within a document.
    THANKS!

  13. #13
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working Code

    I haven't quite worked this out, but FWIW:
    I'm converting a set of WPD via RTF to DOC, then extracting images from within the DOC.
    My code gets to the line<pre>TempPres.Export strNewName, "JPG"</pre>

    and then baulks with "Presentation (unknown member) failed", a.k.a. Run-time error -2147467259.
    The value of strNewName at this point is<pre>J:20080331EnglishADMADM-PGW153I<font color=red>.WPD.DOC</font color=red>.JPG</pre>

    If I lop off extraneous extents and use<pre>strNewName="J:20080331EnglishADMADM-PGW153I.JPG"</pre>

    then the slide/image is saved flawlessly!
    Attached Images Attached Images
    • File Type: jpg 4.JPG (10.3 KB, 0 views)

  14. #14
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving as a GIF (VBA Word 2000)

    >Is there a way to create a macro that will select a block of text and save as a .gif?
    See also this thread <post:=706,955>post 706,955</post:> (19 April 2008) for saving an image from the clipboard to a gif/jpg file.

  15. #15
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Saving as a GIF (VBA Word 2000)

    Hi Chris,

    Take a look at the zip file here:http://www.lebans.com/msword.htm It seems to me that it would be quite straightfoward to use this in conjunction with the CopyAsPicture and PasteSpecial (DataType)methods to convert a range to an image.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Page 1 of 2 12 LastLast

Posting Permissions

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