Jump to content
Sign in to follow this  
LukeJrs

Adding Picture to words

Recommended Posts

LukeJrs

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)

Share this post


Link to post
Share on other sites
autocomplex

; *******************************************************
; 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.

Share this post


Link to post
Share on other sites
LukeJrs

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

Share this post


Link to post
Share on other sites
CrewXp

Did you use a translator.....

Share this post


Link to post
Share on other sites
therks

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. :)

Share this post


Link to post
Share on other sites
big_daddy

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)

Share this post


Link to post
Share on other sites
big_daddy

Just wondering if this did what you needed?

Share this post


Link to post
Share on other sites
LukeJrs

Thanks sorry for the long reply... yes it's what I was looking for to make it work.

Share this post


Link to post
Share on other sites
big_daddy

Your welcome, glad it worked for you.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×