Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert Text to an Image of Text in VBA? (Office 2000 Sr1a)

    I am trying to write a subroutine that will take a block of text in (say) Word and convert this to a GIF
    file or JPG. Is this possible?
    My ultimate aim is to automatically create personalised, pseudo-handwritten text headings to place
    in a web page.
    I've tried cutting and paste picture in Word (recording a macro) but the result does not seem to retain the
    font when put into a web page.
    Any ideas please?

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Convert Text to an Image of Text in VBA? (Office 2000 Sr1a)

    If you create your text in a Text box and then cut it, you will be able to Paste Special as a jpg.
    A recorded macro shows this as Selection.PasteSpecial Datatype:=15,

    StuartR

    edited to add
    It is important that you cut the entire text box for this to work.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert Text to an Image of Text in VBA? (Office 2000 Sr1a)

    Thanks I had thought of this but it does not seem to work with Word 2000.
    That datatype is unavailable, according to the error message. Here are the data
    types that are available:
    DataType Optional Variant. A format for the Clipboard contents when they're inserted into the document. Can be one of the following WdPasteDataType constants: wdPasteBitmap, wdPasteDeviceIndependentBitmap, wdPasteEnhancedMetafile, wdPasteHTML, wdPasteHyperlink, wdPasteMetafilePicture, wdPasteOLEObject, wdPasteRTF, wdPasteShape or wdPasteText. The default format varies, depending on the contents of the Clipboard
    Am I missing something here?

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Convert Text to an Image of Text in VBA? (Office 2000 Sr1a)

    This short piece of test VBA works for me, using Word 2000 SR1a. The only shape in my document was a text box containing the text I wanted...
    Public Sub TestJPG()
    ActiveDocument.Shapes(1).Select
    Selection.Cut
    Selection.PasteSpecial datatype:=15
    End Sub

    Did you put your text into a text box and cut the entire text box before testing?

    StuartR

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert Text to an Image of Text in VBA? (Office 2000 Sr1a)

    Yes! That works fine - I wasn't selecting and copying the textbox - just the text within.
    Thanks for the idea.
    Now I have to figure out a nice routine to paste the resulting image into a Front Page web page.

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

    Re: Convert Text to an Image of Text in VBA? (Office 2000 Sr1a)

    David,

    Here's another way to do it, via PowerPoint: <post#=129034.>post 129034.</post#>

    Gary

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    314
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert Text to an Image of Text in VBA? (Office 2000 Sr1a)

    Very nice idea here, thanks Gary.
    I will use this.
    Seems mad though that we have to invoke powerpoint to do something so simple.
    Oh well, that's Microsoft!
    Thanks again, David.

Posting Permissions

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