• Detecting multi image in word document

    From Silvester Roklasfonoshio@21:1/5 to All on Wed Apr 5 13:42:40 2023
    Hi everybody i have implemented this code to detect more than one image: #define Word_File hb_dirbase() + "MyFileTxt.docx"
    procedure Main
    local oWord
    local oDoc
    local oImgs
    local oShape
    oWord := Win_OleCreateObject( "Word.Application" )
    oWord:Visible := .T.
    oDoc := oWord:documents:open( Word_File )
    if oDoc:InlineShapes:Count > 0

    oImgs := oWord:Documents:Add()
    for each oShape in oDoc:InlineShapes

    oShape:Range:CopyAsPicture()
    oImgs:Paragraphs:Add()
    oWord:Selection:Paste()
    endfor
    endif
    oWord := NIL
    return

    it just only works with one image and when i tested with more than one image i got this erroe:
    Error 121896500/0 S_OK: PASTE

    why and how i can modify this code to make it able to work with more than one image

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dlzc@21:1/5 to Silvester Roklasfonoshio on Thu Apr 6 09:07:12 2023
    On Wednesday, April 5, 2023 at 1:42:41 PM UTC-7, Silvester Roklasfonoshio wrote:
    Hi everybody i have implemented this code to detect more than one image: #define Word_File hb_dirbase() + "MyFileTxt.docx"
    procedure Main
    local oWord
    local oDoc
    local oImgs
    local oShape
    oWord := Win_OleCreateObject( "Word.Application" )
    oWord:Visible := .T.
    oDoc := oWord:documents:open( Word_File )
    if oDoc:InlineShapes:Count > 0

    oImgs := oWord:Documents:Add()
    for each oShape in oDoc:InlineShapes

    oShape:Range:CopyAsPicture()
    oImgs:Paragraphs:Add()
    oWord:Selection:Paste()
    endfor
    endif
    oWord := NIL
    return

    it just only works with one image and when i tested with more than one image i got this erroe:
    Error 121896500/0 S_OK: PASTE

    why and how i can modify this code to make it able to work with more than one image

    You are copying from oWord, and creating and instance in oImgs, but then...
    oWord:Selection:Paste()

    Is that right? I don't do this, so I don't see how you are directing output images to oImgs... just throwing it at the Word.Application and hoping for it to know what you meant to happen.

    David A. Smith

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Silvester Roklasfonoshio@21:1/5 to All on Thu Apr 6 14:30:53 2023
    في الخميس، 6 أبريل 2023 في تمام الساعة 8:07:14 م UTC+4، كتب dlzc رسالة نصها:
    On Wednesday, April 5, 2023 at 1:42:41 PM UTC-7, Silvester Roklasfonoshio wrote:
    Hi everybody i have implemented this code to detect more than one image: #define Word_File hb_dirbase() + "MyFileTxt.docx"
    procedure Main
    local oWord
    local oDoc
    local oImgs
    local oShape
    oWord := Win_OleCreateObject( "Word.Application" )
    oWord:Visible := .T.
    oDoc := oWord:documents:open( Word_File )
    if oDoc:InlineShapes:Count > 0

    oImgs := oWord:Documents:Add()
    for each oShape in oDoc:InlineShapes

    oShape:Range:CopyAsPicture()
    oImgs:Paragraphs:Add()
    oWord:Selection:Paste()
    endfor
    endif
    oWord := NIL
    return

    it just only works with one image and when i tested with more than one image i got this erroe:
    Error 121896500/0 S_OK: PASTE

    why and how i can modify this code to make it able to work with more than one image
    You are copying from oWord, and creating and instance in oImgs, but then...
    oWord:Selection:Paste()

    Is that right? I don't do this, so I don't see how you are directing output images to oImgs... just throwing it at the Word.Application and hoping for it to know what you meant to happen.

    David A. Smith
    Thank you very much for your answer my dear brother ...it works perfectly with one image i mean when the word document has one image it can correctly extract that image and paste it in new word document but when the document has more than one image it
    just paste the first image and give me the previous error i show you previously :
    Error 121896500/0 S_OK: PASTE
    and i dont know why ? so what do suggest ? where is the problem exactly ?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Silvester Roklasfonoshio@21:1/5 to All on Fri Apr 7 14:00:39 2023
    في الجمعة، 7 أبريل 2023 في تمام الساعة 1:30:55 ص UTC+4، كتب Silvester Roklasfonoshio رسالة نصها:
    في الخميس، 6 أبريل 2023 في تمام الساعة 8:07:14 م UTC+4، كتب dlzc رسالة نصها:
    On Wednesday, April 5, 2023 at 1:42:41 PM UTC-7, Silvester Roklasfonoshio wrote:
    Hi everybody i have implemented this code to detect more than one image: #define Word_File hb_dirbase() + "MyFileTxt.docx"
    procedure Main
    local oWord
    local oDoc
    local oImgs
    local oShape
    oWord := Win_OleCreateObject( "Word.Application" )
    oWord:Visible := .T.
    oDoc := oWord:documents:open( Word_File )
    if oDoc:InlineShapes:Count > 0

    oImgs := oWord:Documents:Add()
    for each oShape in oDoc:InlineShapes

    oShape:Range:CopyAsPicture()
    oImgs:Paragraphs:Add()
    oWord:Selection:Paste()
    endfor
    endif
    oWord := NIL
    return

    it just only works with one image and when i tested with more than one image i got this erroe:
    Error 121896500/0 S_OK: PASTE

    why and how i can modify this code to make it able to work with more than one image
    You are copying from oWord, and creating and instance in oImgs, but then...
    oWord:Selection:Paste()

    Is that right? I don't do this, so I don't see how you are directing output images to oImgs... just throwing it at the Word.Application and hoping for it to know what you meant to happen.

    David A. Smith
    Thank you very much for your answer my dear brother ...it works perfectly with one image i mean when the word document has one image it can correctly extract that image and paste it in new word document but when the document has more than one image it
    just paste the first image and give me the previous error i show you previously :
    Error 121896500/0 S_OK: PASTE
    and i dont know why ? so what do suggest ? where is the problem exactly ?
    Iam still waiting for your answer my dear brother .

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)