Hi alll,
i search now for weeks for a solution for my problem:
the export of a picture as bmp in word with vba
(access2002)!

The tool i started with is,

http://www.lebans.com/msword.htm

it's nearly what i need if all would work how it should,
the problem, something goes wrong with the
" horizontal or vertical dissolution "

I think the two decisive methods are(do not frighten a lot of code =)):

VB Code:
  1. Public Function EMFToDIB() As Boolean
  2.     ' Play the Metafile into the DIBSection
  3.     Dim blRet As Boolean
  4.     Dim hDCtemp As Long
  5.     ' Instance of EMF Header structure
  6.     Dim mh As ENHMETAHEADER
  7.     ' Current Screen Resolution
  8.     Dim lngXdpi As Long
  9.     ' Used to convert Metafile dimensions to pixels
  10.     Dim sngConvertX As Single
  11.     Dim sngConvertY As Single
  12.     ' Pels per meter for Bitmapinfo
  13.     ' Some apps will read thsi value to determine DPI for
  14.     ' display purposes
  15.     Dim PelsX As Long, PelsY As Long
  16.     ' Image dimensions
  17.     Dim Width As Long, Height As Long
  18.     Dim hDCref As Long
  19.     Dim rc As RECT
  20.  
  21.     ' Create a temp Device Context
  22.     hDCtemp = CreateCompatibleDC(0)
  23.     ' Get Enhanced Metafile Header
  24.     lngRet = GetEnhMetaFileHeader(m_hEMF, Len(mh), mh)
  25.     With mh.rclFrame
  26.         ' The rclFrame member Specifies the dimensions,
  27.         ' in .01 millimeter units, of a rectangle that surrounds
  28.         ' the picture stored in the metafile.
  29.         ' I'll show this as seperate steps to aid in understanding
  30.         ' the conversion process.
  31.         ' Convert to MM
  32.         sngConvertX = (.Right - .Left) * 0.01
  33.         sngConvertY = (.Bottom - .Top) * 0.01
  34.     End With
  35.     ' Convert to CM
  36.     sngConvertX = sngConvertX * 0.1
  37.     sngConvertY = sngConvertY * 0.1
  38.     ' Convert to Inches
  39.     sngConvertX = sngConvertX / 2.54
  40.     sngConvertY = sngConvertY / 2.54
  41.     ' DC for the enumeration of the EMF records
  42.     'It must be GetDC not CreateCompatibleDC!!!
  43.     hDCref = apiGetDC(0)
  44.     ' See if we can get the original Image dimensions
  45.     ' From an EMRSTRETCHDIBITS metafile record which
  46.     ' will exist for any Images that were
  47.     ' originally Bitmap based.(BMP, Jpeg, Tiff etc.)
  48.     blRet = EnumEMFGetDimension(m_hEMF, hDCref, Width, Height)
  49.     ' Always release the DC as soon as possible
  50.     lngRet = apiReleaseDC(0, hDCref)
  51.     ' Again if Width = 0 then we are dealing with a plain Metafile
  52.     ' not a DIB wrapped within a Metafile.
  53.     ' Get the Dimensions from the Metafile Header.
  54.     If Width = 0 Then
  55.         ' Get the Image dimensions directly from the EMH Header
  56.         Width = mh.rclBounds.Right
  57.         Height = mh.rclBounds.Bottom
  58.     End If
  59.     ' Next we need to check and see which dimension values are
  60.     ' larger, the EnumEMFGetDimension values or the EMF Header values.
  61.     ' Use Whichever values are larger. This logic will cover the
  62.     ' case where we have an origina EMF Image but it happens to
  63.     ' contain one or more calls to the EMRSTRETCHDIBITS record.
  64. '    If mh.rclBounds.right > Width Then
  65. '        Width = mh.rclBounds.Right
  66. '        Height = mh.rclBounds.Bottom
  67. '    End If
  68.     ' The vars sngConvertX and  sngConvertY contain the
  69.     ' dimensions of the Image in inches.
  70.     ' We need to convert this to Pixels Per METER.
  71.     ' First convert to Inches
  72.     PelsX = Width / sngConvertX
  73.     PelsY = Height / sngConvertY
  74.     ' A problem here is that we are too accurate compared to
  75.     ' the rounding used by Word and Explorer. For instance we might
  76.     ' arrive at a value of 302 DPI when Word originally loaded the
  77.     ' Image it was only 300 DPI.
  78.     ' Let's round to the nearest 100th value.
  79.     ' If the value is under 120 then leave it alone
  80.     If PelsX > 120 Then
  81.         PelsX = PelsX + 5
  82.         PelsY = PelsY + 5
  83.         PelsX = PelsX \ 10
  84.         PelsY = PelsY \ 10
  85.         PelsX = PelsX * 10
  86.         PelsY = PelsY * 10
  87.     End If
  88.     ' Now convert Inches to Meters
  89.     PelsX = PelsX * 39.37
  90.     PelsY = PelsY * 39.37
  91.     'PelsX = PelsX * 8.24
  92.     'PelsY = PelsY * 8.24
  93.     'PelsX = 96
  94.     'PelsY = 96
  95.     ' Now create our DIBSECTION
  96.     Create Width, Height, PelsX, PelsY
  97.     '"PLAY" the Enhanced Metafile
  98.     ' back into the Device Context containing the DIBSection
  99.     rc.Top = 0
  100.     rc.Left = 0
  101.     rc.Bottom = m_bmi.bmiHeader.biHeight
  102.     rc.Right = m_bmi.bmiHeader.biWidth
  103.     lngRet = apiPlayEnhMetaFile(m_hDC, m_hEMF, rc)
  104.     ' Success
  105.     EMFToDIB = True
  106. End Function

and:

VB Code:
  1. Public Function SaveEMF(strFname As String)
  2.     Dim lngRet As Long
  3.     Dim blRet As Long
  4.     Dim lLength As Long
  5.     Dim Width As Long
  6.     Dim Height As Long
  7.     Dim hDCEMF As Long
  8.     Dim hDCref As Long
  9.     Dim rc As RECT
  10.     ' local storage for out copy of the EMF Header
  11.     Dim mh As ENHMETAHEADER
  12.     ' Vars to calculate resolution
  13.     Dim sngConvertX As Single
  14.     Dim sngConvertY As Single
  15.     Dim ImageWidth As Single
  16.     Dim ImageHeight As Single
  17.     Dim Xdpi As Single
  18.     Dim Ydpi As Single
  19.     Dim TwipsPerPixelX As Single
  20.     Dim TwipsPerPixelY As Single
  21.     Dim sngHORZRES As Single
  22.     Dim sngVERTRES As Single
  23.     Dim sngHORZSIZE As Single
  24.     Dim sngVERTSIZE As Single
  25.  
  26.     ' To create our EMF
  27.     'It must be GetDC not CreateCompatibleDC!!!
  28.     hDCref = apiGetDC(0)
  29.     ' See if we can get the original Image dimensions
  30.     ' From an EMRSTRETCHDIBITS metafile record which
  31.     ' will exist for any Images that were
  32.     ' originally Bitmap based.(BMP, Jpeg, Tiff etc.)
  33.     blRet = EnumEMFGetDimension(m_hEMF, hDCref, Width, Height)
  34.     ' Again if Width = 0 then we are dealing with a plain Metafile
  35.     ' not a DIB wrapped within a Metafile.
  36.     ' Get the Dimensions from the Metafile Header.
  37.     If Width = 0 Then
  38.         ' Get Enhanced Metafile Header
  39.         lngRet = GetEnhMetaFileHeader(m_hEMF, Len(mh), mh)
  40.         ' It is a plain Metafile we are dealing with
  41.         ' not a DIB wrapped in a Metafile.
  42.         ' Get the Dimensions from the Metafile Header
  43.         Width = mh.rclBounds.Right
  44.         Height = mh.rclBounds.Bottom
  45.     End If
  46.     ' Next we need to check and see which dimension values are
  47.     ' larger, the EnumEMFGetDimension values or the EMF Header values.
  48.     ' Use Whichever values are larger. This logic will cover the
  49.     ' case where we have an origina EMF Image but it happens to
  50.     ' contain one or more calls to the EMRSTRETCHDIBITS record.
  51.     If mh.rclBounds.Right > Width Then
  52.         Width = mh.rclBounds.Right
  53.         Height = mh.rclBounds.Bottom
  54.     End If
  55.     ' Setup
  56.     ' April 19-2004rc.right = Width
  57.     'rc.Bottom = Height
  58.     ImageWidth = Width
  59.     ImageHeight = Height
  60.     ' Calculate the current Screen resolution.
  61.     ' I used to simply use GetDeviceCaps and
  62.     ' LOGPIXELSY/LOGPIXELSX. Unfortunately this does not yield accurate results
  63.     ' with Metafiles.  LOGPIXELSY will return the value of 96dpi or 120dpi
  64.     ' depending on the current Windows setting for Small Fonts or Large Fonts.
  65.     ' Thanks to Feng Yuan's book "Windows Graphics Programming" for
  66.     ' explaining the correct method to ascertain screen resolution.
  67.     ' Let's grab the current size and resolution of our Screen DC.
  68.     sngHORZRES = apiGetDeviceCaps(hDCref, HORZRES)
  69.     sngVERTRES = apiGetDeviceCaps(hDCref, VERTRES)
  70.     sngHORZSIZE = apiGetDeviceCaps(hDCref, HORZSIZE)
  71.     sngVERTSIZE = apiGetDeviceCaps(hDCref, VERTSIZE)
  72.     ' Convert millimeters to inches
  73.     sngConvertX = (sngHORZSIZE * 0.1) / 2.54
  74.     sngConvertY = (sngVERTSIZE * 0.1) / 2.54
  75.     ' Convert to DPI
  76.     sngConvertX = sngHORZRES / sngConvertX
  77.     sngConvertY = sngVERTRES / sngConvertY
  78.     Xdpi = sngConvertX
  79.     Ydpi = sngConvertY
  80.     ' Calculate TwipsPerPixel
  81.     TwipsPerPixelX = TWIPSPERINCH / Xdpi
  82.     TwipsPerPixelY = TWIPSPERINCH / Ydpi
  83.     ' Convert pixels to TWIPS
  84.     ImageWidth = ImageWidth * TwipsPerPixelX
  85.     ImageHeight = ImageHeight * TwipsPerPixelY
  86.     ' Convert TWIPS to Inches
  87.     ImageWidth = ImageWidth / 1440
  88.     ImageHeight = ImageHeight / 1440
  89.     ' Convert Inches to .01 mm
  90.     ImageWidth = (ImageWidth * 2.54) * 1000
  91.     ImageHeight = (ImageHeight * 2.54) * 1000
  92.     ' Ready to call the Create Metafile API
  93.     rc.Bottom = ImageHeight
  94.     rc.Right = ImageWidth
  95.     rc.Left = 0
  96.     rc.Top = 0
  97.     ' Create the Metafile
  98.     hDCEMF = apiCreateEnhMetaFileRECT(hDCref, strFname, rc, vbNullString)
  99.     If hDCEMF = 0 Then
  100.         MsgBox "Could not create Metafile", vbCritical
  101.         lngRet = apiReleaseDC(0, hDCref)
  102.         Exit Function
  103.     End If
  104.     ' Now play the Memory Metafile into our Disk based Metafile
  105.     rc.Bottom = Height
  106.     rc.Right = Width
  107.     lngRet = apiPlayEnhMetaFile(hDCEMF, m_hEMF, rc)
  108.     ' Now close the file based EMF
  109.     lngRet = apiCloseEnhMetaFile(hDCEMF)
  110.     ' Delete it(not really...it merely releases the ref to it completely.
  111.     lngRet = apiDeleteEnhMetaFile(lngRet)
  112.     ' Always release what you get
  113.     lngRet = apiReleaseDC(0, hDCref)
  114. End Function

first it seems everything working however if I try with the method " ConvertBMPtoJPG " (ImageUtils.dll)
to convert the bmp the colours of the converted picture are wrong... i think the reason are the "dpi"
(wrong export from the "WORD-Tool" but where?)

I work with Access 2002 (VBA) makes the thing a little more difficulty!

still as further tip: if I load the exported picture(bmp from Word) into a picture processing program(MS Paint) and save it again as bmp the dpi changes and the picture can be correctly converted with " ConvertBMPtoJPG "!

Im working on a larger project and dont know how to continue would be great if one of u experts can give me a tip!!

greeting Seinfeld=)