Abrubt termination word app using Tbox.Left
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:
'-This code remembers the currect control's position
set Tbox = AppWord.Selection.ShapeRange
if isSHPveld(Tbox) then 'check of selection is textbox shape
tk = tbox.AlternativeText 'oke
NoMoveL = Tbox.Left 'oke
NoMoveT = Tbox.Top 'oke
end if
if isSHPPicure(Tbox) then 'check if selection is picture
tk = tbox.AlternativeText 'oke
NoMoveL = Tbox.Left 'causes an abrubt termination of word application
'or
debug.print Tbox.Left 'allso causes an abrubt termination
end if
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.