I use Word automation in my VB6 application
I'm trying to lock the contols textbox shapes and pictures on it's position,
so the user can't move them. I got this to work with the textbox shapes, but now with a picture word closes on me, altough code is exact the same.

A small code snippet:


VB Code:
  1. '-This code remembers the currect control's position
  2. set Tbox = AppWord.Selection.ShapeRange
  3. if isSHPveld(Tbox) then 'check of selection is textbox shape
  4.   tk = tbox.AlternativeText 'oke
  5.   NoMoveL = Tbox.Left 'oke
  6.   NoMoveT = Tbox.Top 'oke
  7. end if
  8.  
  9. if isSHPPicure(Tbox) then 'check if selection is picture
  10.   tk = tbox.AlternativeText 'oke
  11.   NoMoveL = Tbox.Left 'causes an abrubt termination of word application
  12.   'or
  13.   debug.print Tbox.Left 'allso causes an abrubt termination
  14. end if
  15.  
  16. exit function 'exit, make sure nog more code influences the result


The code above is run when a user left mousecliks the word application.
I tested with a textbox shape and works fluently.
I tested with one picture in the doc and after a few times of clicking on the picture and moving the picture,
i get a word errormessage 'Microsoft Word encountered a problem and needs to close. I'm sorry for the inconveniance...
and then word closes itself.
I know the line where it goes wrong , thats : NoMoveL = Tbox.Left
Somehow it can't gets the left or top value sometimes.