Read Picture Type?

J

JethroUK©

I can set an inline picture datatype as e.g. jpeg, metafile, ,etc

but how can i read existing picture type:

With ActiveDocument
For x% = 1 To .InlineShapes.Count
msgbox .InlineShapes(x%).Type ?????
 
J

Jezebel

Graphics, once inserted into the document, don't have a type. Within Word,
all graphics are WMFs. That's why the graphics format you selected when you
installed Word are called 'converters'.
 
J

JethroUK©

if all graphics are windows metafiles - how come i can cut a picture and
paste it back as .jpeg, .gif, png or bitmap (all have different 'type'
numbers)

in fact, the whole point of my routine is to convert non-metafiles to
metafile - hence i want to detect the picture type before converting it
 
J

Jezebel

JethroUK© said:
if all graphics are windows metafiles - how come i can cut a picture and
paste it back as .jpeg, .gif, png or bitmap (all have different 'type'
numbers)

This is functionality of the clipboard, not of Word.
 
J

JethroUK©

so your statement "Graphics, once inserted into the document, don't have a
type."

isn't true - they do have a 'type', which can be defined/written within m.s.
word - i just cant find a way to read the type before writing it - hence my
problem & my post
 
J

Jezebel

Wishful thinking is not a good basis for writing code. As you've
demonstrated already, it doesn't work.
 
J

JethroUK©

m.s. word is compatable with many different picture types. jpeg, gif, png,
bitmap, metafiles - i cant help it if you dont know that, and a
condescending attitude wont disguise ignorance - the google archives will
carve this thread in stone for years - so the wiser approach would be to
admit you've waded out of your depth & leave the thread with your
credibility intact

f.y.i. i have already written the code that works perfectly:

Sub CompressPictures()

Dim x%

With ActiveDocument.InlineShapes
For x% = 1 To .Count
.Item(x%).Select
Selection.Cut
Selection.PasteSpecial , , wdInLine, , wdPasteMetafilePicture
Next
End With

End Sub

i merely would prefer to read a picture type before i write it - if you dont
know - leave it for someone who does - k
 
J

Jezebel

You're resolutely missing the point. Word supports any number of graphics
filters, for the file formats you mention and umpteen others. These filters
are known as 'converters' for good reason: they convert to and from Word's
internal graphic format. The internal format is WMF.
 
J

JethroUK©

can you see what the code does?

can you see it replaces any/all picture 'types' with wmf?

can you see it would be wise - to only replace the ones that are 'not' wmf
already?

can you see it nessessary to be able to read the existing type to
differentiate?

if you are saying it can't be done - just say so - m.s. word picture typing
is only a very, very small part of my life
 
J

Jezebel

Yes I CAN see what the code does. It uses the wdPasteMetafilePicture
constant to specify which of the various data formats in the clipboard
should be used as the source for the paste operation. This has nothing to do
with the format of the graphic once it has been pasted into the document.

The Clipboard is an application in its own right. When you copy something to
the clipboard, the copying application chooses which data formats it will
put into the clipboard (as a service to the - at that point unknown -
pasting application). The options listed when you use Edit > PasteSpecial
are the formats actually held by the clipboard at the time, that Word can
use.

The argument to the PasteSpecial method -- wdPasteMetafilePicture in this
case -- is not specfying what format should be inserted into Word, but which
of the source formats within the clipboard object to use. The result of the
paste is a conversion of that source to Word's internal format -- WMF in all
cases if the source is a graphic format.

You might get a better understanding of what's going on by looking at the VB
documentation for the Clipboard object. If you don't have VB, Google should
find it for you.
 
J

JethroUK©

i'll take that as no, and carry on replacing every picture, in all the
documents indiscriminately

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top