WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: rickmds on May 05, 2016, 05:07:45 AM

Title: Extracting a URL from a hyperlink on Excel with winBatch?
Post by: rickmds on May 05, 2016, 05:07:45 AM
Hi
I just ran across this VB macro and would like to do this with Winbatch.  Can someone help with the conversion?
Many Thanks
Rick

Extracting a URL from a hyperlink on Excel is easy!
Option 1: If you want to run this operation one time

    Open up a new workbook.
    Get into VBA (Press Alt+F11)
    Insert a new module (Insert > Module)
    Copy and Paste the Excel user defined function below
    Press F5 and click ââ,¬Å"Runââ,¬Â
    Get out of VBA (Press Alt+Q)

Sub ExtractHL()
Dim HL As Hyperlink
For Each HL In ActiveSheet.Hyperlinks
HL.Range.Offset(0, 1).Value = HL.Address
Next
End Sub
Title: Re: Extracting a URL from a hyperlink on Excel with winBatch?
Post by: td on May 05, 2016, 06:36:48 AM
There are numerous Excel examples in the Tech Database.  Take a look.   You might also want to look at the 'ForEach' statement and  the COM tutorial  in the Consolidated WIL Help file, if you are unfamiliar with using COM Automation in WinBatch scripts.

If you get stuck post what you have and someone will help.
Title: Re: Extracting a URL from a hyperlink on Excel with winBatch?
Post by: td on May 06, 2016, 01:57:22 PM
Happened to find this and modified it to use your offset business.  Hope it helps

Code (winbatch) Select
objExcel = ObjectCreate('Excel.Application')

objExcel.Visible          = 1 
objExcel.ScreenUpdating   = 1   
objExcel.UserControl      = 1
objExcel.DisplayAlerts    = 0
objExcel.Workbooks.Open(dirscript():"Stupid.xlsx")

objWS = objExcel.Workbooks(1).Worksheets(1)
objWS.Activate()
ForEach objHyper In objExcel.ActiveSheet.Hyperlinks
  objHyper.Range.Offset(0, 1).Value = objHyper.Address
next

objExcel.ActiveWorkbook.Save
objExcel.Quit()
objExcel = 0
Title: Re: Extracting a URL from a hyperlink on Excel with winBatch?
Post by: rickmds on May 09, 2016, 04:11:02 AM
Thank you very much TD!