Jump to content
Sign in to follow this  
Messy_Code_Guy

Need a sample of how to find a picture and add a hypelink in a Word document.

Recommended Posts

You could set the AlternativeText when creating the Word document and check that in your script:

#include <Word.au3>
$oWord = _Word_Create()
$oDoc = _Word_DocOpen($oWord, "C:\temp\Default RMLO_SIG.docx")
$FBName = "http://www.facebook.com"
; Set Picture 1 to Facebook
_Word_DocLinkAdd($oDoc, $oDoc.InlineShapes(1).Range, $FBName, Default, "Click here to visit my facebook page. " & @CRLF & $FBName, "FB")
; Loop through the InlineShape collection and display some information for each picture
For $oShape In $oDoc.InlineShapes
    ConsoleWrite($oShape.Name & " - " & $oShape.AlternativeText & " - " & $oShape.Hyperlink.Address & @CRLF)
Next

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

Water-

I think this will work.  I will try this later today and let you know how it goes. :)


 

"The only thing necessary for the triumph of evil is for good men to do nothing".

Edmund Burke
 

Share this post


Link to post
Share on other sites

Water-

I am getting this error:

"C:\Temp\Word_Test3.au3" (35) : ==> The requested action with this object has failed.:
ConsoleWrite($oShape.Name & " - " & $oShape.AlternativeText & " - " & $oShape.Hyperlink.Address & @CRLF)
ConsoleWrite($oShape^ ERROR

Here is the code I was using.

#include <MsgBoxConstants.au3>
#include <Word.au3>
#include <File.au3>



Local $oWord = _Word_Create(True, True)
If @error Then
    $file1 = FileOpen(@ScriptDir & "\Error_LOG.txt", 9)
    _FileWriteLog($file1, "," & @ComputerName & "," & @UserName & ",Error creating a new Word application object." & " @error = " & @error & " @extended = " & @extended)
    FileClose($file1)
EndIf

Local $sDocument = @ScriptDir & '\Default RMLO_SIG.mht'
Local $oDoc = _Word_DocOpen($oWord, $sDocument, Default, Default, False)
If @error Then
    $file1 = FileOpen(@ScriptDir & "\Error_LOG.txt", 9)
    _FileWriteLog($file1, "," & @ComputerName & "," & @UserName & ",Error opening " & $sDocument & " @error = " & @error & " @extended = " & @extended)
    FileClose($file1)
EndIf
$Google = "http://www.google.com"
; Set Picture 1 to Facebook
_Word_DocLinkAdd($oDoc, $oDoc.InlineShapes(2).Range, $Google, Default, "Click here to visit Google.com. " & @CRLF & $Google, "G")
If @error Then
    $file1 = FileOpen(@ScriptDir & "\Error_LOG.txt", 9)
    _FileWriteLog($file1, "," & @ComputerName & "," & @UserName & ",Error setting link in image " & $Google & " @error = " & @error & " @extended = " & @extended)
    FileClose($file1)
EndIf

$FBName = "http://www.facebook.com"
; Set Picture 1 to Facebook
_Word_DocLinkAdd($oDoc, $oDoc.InlineShapes(1).Range, $FBName, Default, "Click here to visit my facebook page. " & @CRLF & $FBName, "FB")
; Loop through the InlineShape collection and display some information for each picture
For $oShape In $oDoc.InlineShapes
    ConsoleWrite($oShape.Name & " - " & $oShape.AlternativeText & " - " & $oShape.Hyperlink.Address & @CRLF)
    If @error Then
    $file1 = FileOpen(@ScriptDir & "\Error_LOG.txt", 9)
    _FileWriteLog($file1, "," & @ComputerName & "," & @UserName & ",Error setting link in image " & $FBName & " @error = " & @error & " @extended = " & @extended)
    FileClose($file1)
EndIf
Next
If @error Then
    $file1 = FileOpen(@ScriptDir & "\Error_LOG.txt", 9)
    _FileWriteLog($file1, "," & @ComputerName & "," & @UserName & ",Error setting link in image " & $FBName & " @error = " & @error & " @extended = " & @extended)
    FileClose($file1)
EndIf

$FBName = "http://www.facebook.com"
; Set Picture 1 to Facebook
_Word_DocLinkAdd($oDoc, $oDoc.InlineShapes(1).Range, $FBName, Default, "Click here to visit my facebook page. " & @CRLF & $FBName, "FB")
For $oShape In $oDoc.InlineShapes
    ConsoleWrite($oShape.Name & " - " & $oShape.AlternativeText & " - " & $oShape.Hyperlink.Address & @CRLF)
    If @error Then
    $file1 = FileOpen(@ScriptDir & "\Error_LOG.txt", 9)
    _FileWriteLog($file1, "," & @ComputerName & "," & @UserName & ",Error setting link in image " & $FBName & " @error = " & @error & " @extended = " & @extended)
    FileClose($file1)
EndIf
Next

If @error Then
    $file1 = FileOpen(@ScriptDir & "\Error_LOG.txt", 9)
    _FileWriteLog($file1, "," & @ComputerName & "," & @UserName & ",Error setting link in image " & $FBName & " @error = " & @error & " @extended = " & @extended)
    FileClose($file1)
EndIf

$Google = "http://www.google.com"
; Set Picture 1 to Facebook
_Word_DocLinkAdd($oDoc, $oDoc.InlineShapes(2).Range, $Google, Default, "Click here to visit Google.com. " & @CRLF & $Google, "G")
If @error Then
    $file1 = FileOpen(@ScriptDir & "\Error_LOG.txt", 9)
    _FileWriteLog($file1, "," & @ComputerName & "," & @UserName & ",Error setting link in image " & $Google & " @error = " & @error & " @extended = " & @extended)
    FileClose($file1)
EndIf

Thanks for the help!


 

"The only thing necessary for the triumph of evil is for good men to do nothing".

Edmund Burke
 

Share this post


Link to post
Share on other sites

Which version of AutoIt do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

With AutoIt 3.3.14.x you need a COM error handler. If none is defined every COM error crashes your script.

Global $__goError = ObjEvent("AutoIt.Error", "__Excel_COMErrFunc") ; At the top of your script

Function __Excel_COMErrFunc comes with the Excel UDF.
For details see ObjEvent in the help file.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-30 - Version 1.6.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (NEW 2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Gowrisankar
      Dear members of the forum,
      I'm working on a project in which I have to use Image recognition technique. 
      Due to client restrictions, I couldn't use AutoIt for this project. 
      Is there a way to use this DLL "ImageSearchDLL.dll" (which is used to do image recognition steps in AutoIt) in VB.Net to achieve the same result? 
      I have used this DLL few years before and got good results. If there is a latest version of this DLL and if you can share it, that will be helpful too.
      Any guidance is deeply appreciated.
    • By Cengokill
      Hi everyone,
      I have created a ListView that is in a tab, and I want to display an image in that tab, with the ListView on top.
      However, the image still appears on top of my ListView.
      If I remove the tabs everything works. 
      I looked at the autoit documentation and the <GuiListView.au3> documentation , I can't figure out how to display a background image, and put on top a ListView, inside a tab. 😥
      Here is the code:
      Opt("GUIOnEventMode", 1) $Form1 = GUICreate($Titre, 700, 627, $Form1Width, $Form1Height); main window $tabulation = GUICtrlCreateTab(148,0,700,580); creating tabs $tab1=GUICtrlCreateTabItem("Tab 1"); first tab GUICtrlSetState(-1, $GUI_SHOW); this tab is selected by default $Pic1 = GUICtrlCreatePic("image.jpg", 0, 30, 700, 627) GUICtrlSetState(-1, $GUI_DISABLE). $idListview = GUICtrlCreateListView("list 1|list 2|list 3", 200, 50, 390, 200) GUISetState(@SW_SHOW) While 1     Sleep(100) WEnd Thank you in advance.

    • By amosrinat
      Hi,
      i have an AutoIT script that sends emails with two embedded images.
      When users get the email they don't see the images. How should I fix my code?
      Thank you for your support,
      Amos
      Func fSendMail() $TemplateName = StringRegExpReplace($Template, "^.*\\|\..*$", "") $SmtpServer = "smtp.**.com" $FromName = "do-not-reply@*********" $FromAddress = "do-not-reply@******" $ToAddress = $MG1_Mgr & ";"& $Owner $Subject = "ACTION REQUIRED - " & $TemplateName $Body = $sBody5 $IPPort = 25 $ssl = 0 Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = fINetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $IPPort, $ssl) If @error Then MyErrFunc() EndIf EndFunc;fSendMail Func fINetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $IPPort = 25, $ssl = 0) Local $objEmail = ObjCreate("CDO.Message") $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" $objEmail.Subject = $s_Subject If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer If Number($IPPort) = 0 Then $IPPort = 25 $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort $objEmail.Configuration.Fields.Update $objEmail.Fields.Update ;$objEmail.Send **************** If @error Then MyErrFunc() EndIf $objEmail = "" EndFunc;fINetSmtpMailCom  
    • By coronatuss
      Hello everyone,
      Im developing an script to check the size of all .jpg stored in windows folder.
      The problem is that it doesn´t work properly with rotated images. 
      With _GDIPlus_ImageGetWidth() and _GDIPlus_ImageGetHeight()  I get the Width and Height of images as if they had not been rotated, and I need to know how they are rotated (orientation and grades).
      Any help is welcome! If more info is needed, please tell. 😁
    • By nacerbaaziz
      hello autoit team
      please i've a question for you.
      am creating a audio player
      and in this audio player i want to show the current trac info
      such as the total time and the position ... etc
      i know i can show it as label
      but the screen reader for the blind read the text every change
      because it have a screen scan
      what i want is to show this informations but such image or icon
      i mean i need to create
      GUICtrlCreatepic or GUICtrlCreateicon ....
      or some thing as that
      and show this informations as image on it
      i think that i can do that with the 
      _GDIPlus functions
      but i couldn't find the currect way to do it
      i tried the _GDIPlus_GraphicsDrawString
      but i couldn't know how it work
      what i need is a small example that create a GUI
      and add a multy line text to it as graphic or image.
      so i need a simple way because it will changed every sec
      i hope any one can help me to do that
      global $GUI = GUICreate("text", 400, 400) global $label = GUICtrlCreateLabel(GetText(), 10, 10, 380, 380) GUISetState() do sleep(100) until GUIGetMSG() = -3 exit func GetText() return StringFormat("file name is test.mp3 \r\n total time is 00:30:00 \r\n position is 00:05:50") endFunc  
×
×
  • Create New...