Control picture in text box

I place  signature picture to textbox programmatically using bookmark and try to control it'sdeletetion by user with AlternativeText property.
Here Power Builder script:
If lole_Word.ActiveDocument.Bookmarks.Exists("signature_image") = True Then
   lole_Word.ActiveDocument.Bookmarks.Item("signature_image").Select()
   lole_Word.Application.Selection.InlineShapes.AddPicture(is_sign_filename, False, True)
   ll_count = lole_Word.ActiveDocument.InlineShapes.Count
   if ll_count > 0 then        lole_Word.ActiveDocument.InlineShapes[ll_count].AlternativeText=_'sign_image_name'             lole_Word.ActiveDocument.Bookmarks.Item("signature_image").Delete()
      end if
End If

But ll_count does not changes and new picture does not appears in This.ole_word.Object.Application.ActiveDocument.Shapes[].
How I can control if signature picture exists in document?
There is no problem when I pplacing picture to main document, only with textbox.
Vitaly PshenichniiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
The new InLineShape isn't added to the document's InLineShapes collection because it is in another StoryRange. However you can capture the new InLineShape directly, so you don't need to look at the collection at all.
I don't know Powerbuilder, but it looks similar VBA. This VBA code works:
Sub Q28743126()
Dim is_sign_filename As String
Dim lole_Word As Word.Application
Dim ll_count As Integer
Dim ilsh As InlineShape

Set lole_Word = Application

is_sign_filename = "C:\Users\Graham Skan\Pictures\2014_0618\2014_06180001.jpg"
If lole_Word.ActiveDocument.Bookmarks.Exists("signature_image") = True Then
    Set ilsh = lole_Word.Application.Selection.InlineShapes.AddPicture(is_sign_filename, False, True)
    ilsh.AlternativeText = "sign_image_name"
    lole_Word.ActiveDocument.Bookmarks.Item("signature_image").Delete
End If
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitaly PshenichniiAuthor Commented:
Thank you,
key phrase is "InLineShapes collection because it is in another StoryRange".
With this I have found the solution how to find signature  image   in the document too:

// to check if exists sign image in document marked with AlternativeText = as_var
Long     ll_count, ll_count_in_shape
Long     ll_i, ll_j
Boolean  lb_exists

ll_count = This.ole_word.Object.Application.ActiveDocument.Shapes.Count
FOR ll_i = 1 TO ll_count
      This.ole_word.Object.Application.ActiveDocument.Shapes[ll_i].Select()
      ll_count_in_shape = This.ole_word.Object.Application.Selection.InlineShapes.Count
      FOR ll_j = 1 TO ll_count_in_shape
             If This.ole_word.Object.Application.Selection.InlineShapes[ll_j].AlternativeText = as_var Then
                   lb_exists = true
                   exit
             end if
      NEXT
NEXT


Is it possible to do better?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.