Jump to content

Adding Picture to words


Recommended Posts

The following help I need is words. It collect picture from windows folder but

can I have it to instead of addpicture comamnd paste the picture i capture with

then save it, now what if file does exists? Can it be opened then add more picture on next line without earing all picture added previewsly?

CODE

; *******************************************************

; Example 1 - Create a word window with a new blank document,

; then add some pictures to the document.

; *******************************************************

;

#include <Word.au3>

$sPath = @WindowsDir & "\"

$search = FileFindFirstFile($sPath & "*.bmp")

; Check if the search was successful

If $search = -1 Then

MsgBox(0, "Error", "No images found")

Exit

EndIf

$oWordApp = _WordCreate ()

$oDoc = _WordDocGetCollection ($oWordApp, 0)

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

$oShape = _WordDocAddPicture ($oDoc, $sPath & $file, 0, 1)

If Not @error Then $oShape.Range.InsertAfter (@CRLF)

WEnd

; Close the search handle

FileClose($search)

Link to comment
Share on other sites

; *******************************************************
; Example 1 - Create a word window with a new blank document,
; then add some pictures to the document.
; *******************************************************
;
#include <Word.au3>

$sPath = @WindowsDir & "\"
$search = FileFindFirstFile($sPath & "*.bmp")

; Check if the search was successful
If $search = -1 Then
MsgBox(0, "Error", "No images found")
Exit
EndIf

I dont fully understand what you are trying to do.

Link to comment
Share on other sites

The script add picture that is located in windows into word document. Well I would like to hit PrintScreen and then paste in word document. then save it. Let hypothetically If there was a file exists like

CODE

If FileExists("D:\test.doc") Then

_WordDocOpen (blah,blah.blah,codes,codes, "D:\test.doc")

_WordDocAddPicture("^{V}")

Else

_WordCreate ("")

_WordDocAddPicture("^{V}")

and save as test.doc

EndIf

Let get to the point! I would like words to paste the printscreen i got on my clipboard also save it on words file automaticly.....

If words doesn't exists then create one and save it automaticly if words does exists then open existen file then modify add new picture to words to the next line and save automaticly

Edited by LukeJrs
Link to comment
Share on other sites

I think he's looking for an algorithm something like this...

If Word document (test.doc) exists, open it, paste image from clipboard (from PrintScreen) into document, then save.

Else, create new document, paste image from clipboard (from PrintScreen) into document, then save as test.doc.

Something like that perhaps?

And no, there's no way he used a translator, because there's no translator that would spell "automaticly" like that. :)

Link to comment
Share on other sites

  • Moderators

This should do what you need.

#include <Word.au3>

;WdCollapseDirection
Const $wdCollapseStart = 1
Const $wdCollapseEnd = 0

$sFilePath = @ScriptDir & "\ScreenCap.doc"

_WordErrorHandlerRegister()
$oWordApp = _WordCreate("", 0, 0)
; Open the specified word document or create it if it doesn't exist
$oDoc = _WordDocOpen($oWordApp, $sFilePath)
$oRange = $oDoc.Content
$oRange.Collapse ($wdCollapseEnd)
; Capture the whole screen
;~ Send("{PRINTSCREEN}")
; Capture the active window
Send("!{PRINTSCREEN}")
$oRange.Paste
_WordQuit($oWordApp, -1)
Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...