Results 1 to 1 of 1

Thread: Positioning a button next to a textboxshape

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Positioning a button next to a textboxshape

    I'm using Word automation in my VB6 application.
    *What i want to do:
    -I have several textbox shapes. When i click in one (Postalcode) i am showing a button (is a small vb form, so the word textboxshape keeps focus).
    This allready works fine. Only i can't get the form/button to position corectly.
    I want it placed right to the active TextBoxshape. The problem is getting the correct screen x y for this to place my form. I can't use api GetCursorPos because this follows the mousecursor and is not reliable. Getting the textbox x y i can do

    VB Code:
    1. set Tbox = Appword.selection.ShapeRange
    2. pt.x =  scalex( Tbox.left, vbpoints,vbtwips)
    3. pt.y =  scaley(tbox.top,vbpoints, vbtwips)
    4.  
    5. frmPostalCode.show vbmodeless
    6. frmPostalCode.Move pt.x, pt.y

    'I probable should allso add the Word window left and top.
    pt.x = scalex( Tbox.left + AppWord.left, vbpoints,vbtwips)
    pt.y = scaley(tbox.top+AppWord.Top,vbpoints, vbtwips)[/code]
    Only these x y values aren't correct (to small) probably caused by the word document's position having gray area around , i should then proably get the coordinates of the left top position of the white document leftup corner.

    *An alternative solution would be to create a button/picture in word doc itself.
    Only more difficult to keep the focus on the active textboxshape. Allso a don't wonna use a command button (try to avoid using the Word build in VBA designer). The above solution with vbform seems better to me.

    The result wil be this. Word document is open. User clicks on postal textbox shape, a arrowbutton amerges. User clicks arrowbutton and a dbgrid form popsup and user browses to the destination corresponding and pushes the arrowbutton again, which now fills in the Locationfield next to the postalcodefield/textboxshape.
    Last edited by lvermeersch; Nov 22nd, 2005 at 02:09 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width