Extracting a URL from a hyperlink on Excel with winBatch?

Started by rickmds, May 05, 2016, 05:07:45 AM

Previous topic - Next topic

rickmds

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

td

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

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
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade