Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Oct 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Resize embedded OLE object to fit screen? (2000/sp3)

    So I've now got an embedded PowerPoint slide (OLE object) on a form in my database... It's effectively my "whiteboard" to draw out representations of data within the database..

    The next step I'd like to try is to be able to resize the form and its contents (my "whiteboard") to the screen. I'm using it effectively as a "preview" mode, so I would like to allow for as much screen real estate as possible...

    I've written some code to resize the window to some value slightly less than the maxmium screen size, but cannot for the life of me resize the embedded powerpoint slide. When I try to do so, it just disappears from the screen. (when I go into design mode on the form, it is there again, in its original size)

    Any ideas?
    ..dane

    Here's the code I've got so far..

    <pre>Private Sub form_Load()

    Dim sldPanelPreview As PowerPoint.Slide

    Dim sglWindowWidth As Single
    Dim sglWindowHeight As Single
    Dim lngTwipBuffer As Long

    ' need a refernce...
    Set sldPanelPreview = Me!pptPanelPreview.Object

    ' Remove all shapes on the slide to have a clean slate...
    If sldPanelPreview.Shapes.Count > 0 Then _
    sldPanelPreview.Shapes.Range.Delete

    ' done with the reference
    Set sldPanelPreview = Nothing

    ' window setup...
    Me.ScrollBars = 0
    Me.NavigationButtons = False

    ' we want to see the WHOLE thing...
    ' but we can only resize stuff in a 'restored' mode..
    ' so we'll maximize to get the screen size, and then
    ' restore to resize things..
    ' we need the TWIPS value...
    DoCmd.Maximize
    sglWindowWidth = Me.InsideWidth
    sglWindowHeight = Me.InsideHeight
    DoCmd.Restore

    ' now let's try and resize this stuff...
    ' 1440 twips = 1", so we'll go 1" from screen edges to be safe
    ' and we'll center...
    lngTwipBuffer = (1440 * 2) ' 1440 twips = 1"
    DoCmd.MoveSize lngTwipBuffer / 2, lngTwipBuffer / 2, _
    sglWindowWidth - lngTwipBuffer, sglWindowHeight - lngTwipBuffer

    ' Now... let's resize the slide to fit the new form.
    pptPanelPreview.Width = Me.InsideWidth / 1440 ' width in inches
    pptPanelPreview.Height = Me.InsideHeight / 1440 ' height in inches

    End Sub
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Resize embedded OLE object to fit screen? (2000/sp3)

    You can use the On Resize event of the form:

    Private Sub Form_Resize()
    With Me.pptPanelPreview
    Width = Me.InsideWidth - 360
    .Height = Me.InsideHeight - 360
    End With
    End Sub

    The 360 corresponds to 1/4 inch; adjust as needed. If you like, you can maximize the form when it opens:

    Private Sub Form_Load()
    DoCmd.Maximize
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Oct 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resize embedded OLE object to fit screen? (2000/sp3)

    Thanks... for some reason I thought the .width/height properites were wanting inches instead of twips, so I had the .insidewidth property divided by 1440 (twips in an inch). That's what went wrong -- it was too small! :-)

    Next question; is there anyway to learn the maximum screen size withOUT actually resizing a window? Hmm... maybe I can use the .visible property to maximize, grab the size, then go back.... I'll try and report back.

    ..dane

  4. #4
    2 Star Lounger
    Join Date
    Oct 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resize embedded OLE object to fit screen? (2000/sp3)

    Looks like the following wouldn't work, because maximizing inherently makes the form visible again...

    <pre> Me.Visible = False
    DoCmd.Maximize
    sglWindowWidth = Me.InsideWidth
    sglWindowHeight = Me.InsideHeight
    DoCmd.Restore
    Me.Visible = True
    </pre>


    I don't see anything in the screen object either, that would tell me maximum available screen size. And furthermore, when you 'maximize' a form, it looks like it overlaps the Windows toolbar (at least with Off2k/Win2k). I'd really like the maximum desktop size, not maximum screen size...

    ideas?
    ..dane

  5. #5
    2 Star Lounger
    Join Date
    Oct 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Resize embedded OLE object to fit screen? (2000/sp3)

    Edited by HansV to provide link to post and to MSKB article - see <!help=19>Help 19<!/help>

    Found <post#=30459>post 30459</post#> that has a routine to query WIndows API for the screen resolution...

    Found an <!mskb=210590>Microsoft Knowledge Base Article 210590<!/mskb> regarding how to convert Twips to Pixels. Reversed the algorithm to make a PixelToTwip conversion.

    Module is attached for anyone to reference...

    ..dane

Posting Permissions

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