Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2008
    Posts
    189

    Question Unanswered: Automatically fit OLE object size in a Report with embed image size?

    Hello,
    Ok, my post title is not simple; so let me try to explain.

    I have a table who has as fild that is a OLE object type.
    This field has some images pasted as bitmaps.
    The image size changes with every single record.

    In the other side, I have a Report that shows the content of this table.
    So, when it comes to the "image" I need to resize the OLE object (that has the source of this mentioned OLE object field) in order to see the hole picture.

    I know that I can do a Shrink or Zoom to the picture... But I want to see the complete picture in the original size.

    Any ideas how?
    Any ideas how to know the real size of the bitmap pasted on the table field? So I will be able to change the size of the OLE object in the Report OnFormat?

    Code:
    Private Sub Detalle_Format(Cancel As Integer, FormatCount As Integer)
    Me.Control.Size=10
    End Sub
    Thanks!!!

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    I need to resize the OLE object
    I want to see the complete picture in the original size.
    I don't 100% know what you want tbh, at first these seem to be in conflict.

    I also don't work with OLE objects in tables, only linked files in object frames. However, the control size properties (width and height) can be set with VBA;

    Me.ControlName.Width = "3cm"

    But determining the right width of the object needed is something I haven't done before.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Apr 2008
    Posts
    189
    Hello,

    Ok, I know how to change the Control Size... but I need first to know the size of the element on the OLE field on the table.

    Any ideas how to know the size of the OLE Object on the table field?

    Thanks!

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    There has to be a way, but I am currently unaware of it...
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Apr 2008
    Posts
    189
    OK... So... I'll have to google-it

    As always: thanks for all your support, help and good-vibes

    BTW; if I find the solution: I'll post it.

  6. #6
    Join Date
    Apr 2008
    Posts
    189
    OK, here is a Lebans solution:

    AutoSizeOLE


  7. #7
    Join Date
    May 2010
    Posts
    2

    how to implement in an existing DB?

    I'd like to use this module, but haven't used modules before. Could anyone help me out with how to implement this in my own existing DB? Where do the links occur between the form/report and the module?

  8. #8
    Join Date
    Apr 2008
    Posts
    189
    Have you seen the Lebans example?

  9. #9
    Join Date
    May 2010
    Posts
    2

    example

    I took a look at the example, and see that there are two parts to the module. I get the overall action that is happening, but I'm a bit confused when it comes to taking this code and applying it to an existing database with existing tables and forms. I'm not sure what the best way is to update my current DB to use this.

  10. #10
    Join Date
    Apr 2008
    Posts
    189
    It's easy.
    Just copy the module "modOLEtAutoSize" to your MDB file.

    Also, add the next function to your code:

    Code:
    Private Sub AutoSizeOLE(ctl As Access.Control)
    ' Junk var
    Dim lngRet As Long
    
    ' Vars to be filled in by
    ' GetOLEImageDimensions function
    Dim IWidth As Long
    Dim IHeight As Long
    
    On Error GoTo Err_handler
     
    ' Call the OLE Action Verb to cause the
    ' control to copy its contents to the ClipBoard
    Me.OLEBoundAutosize.Action = 4
    DoEvents
      
    ' Call our function that will return a handle to
    ' the Metafile on the ClipBoard
    lngRet = GetOLEImageDimensions(IWidth, IHeight)
    Me.OLEBoundAutosize.width = IWidth
    Me.OLEBoundAutosize.Height = IHeight
    Exit Sub
    
    Err_handler:
    MsgBox Err.Description, vbCritical, Err.Number
    
    End Sub
    Next use the function "AutoSizeOLE" to each object you want to auto-size.

    Like this:
    Code:
    AutoSizeOLE Me.OLEBoundAutosize
    And will auto-size the object according the content.

    By the way: the content will be copied to the clipboard in order to analize the size.

  11. #11
    Join Date
    Apr 2008
    Posts
    189
    Quote Originally Posted by jessicamreinhardt View Post
    [...] I'm not sure what the best way is to update my current DB to use this.
    Sorry, update what?
    You mean, to add this code?

Posting Permissions

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