I work with a BI program, QlikView, that has native export to Excel, but which can't export hyperlinks. I wrote a macro to do this ("wrote" is a misnomer; I cobbled it together from bits and pieces
I found elsewhere):
I found elsewhere):
Code:
Sub ExportToExcel()
Const xlShiftToRight = -4161
Const xlPasteValues = -4163 '(&HFFFFEFBD)
Const xlPasteSpecialOperationNone = -4142 '(&HFFFFEFD2)
Set XLApp = CreateObject("Excel.Application") 'Creating excel instance in VB Script
XLApp.Visible = True 'Settting the value to False, so this happens in background
Set XLDoc = XLApp.Workbooks.Add 'Creating new excel workbook
XLDoc.Sheets(1).Name = "Auditor WS" 'Adding the sheet name as Export
Set XLSheet = XLDoc.Worksheets(1) 'Setting the XLSheet
Set MyTable = ActiveDocument.GetSheetObject("CH47") 'Setting MyTable variable to current QlikView Object
MyTableCount = MyTable.GetRowCount
Set XLSheet = XLDoc.Worksheets(1) 'Select sheet where data should be pasted
Mytable.CopyTableToClipboard True 'Copy data to Clipboard
XLSheet.Paste XLSheet.Range("A1") 'Paste data starting at a1
' Set objRange = objExcel.Range("Y:Y").EntireColumn
XLSheet.Columns("Y:Y").Insert xlToRight
' objRange.Insert(xlShiftToRight)
' Columns("Y:Y").Select
' Selection.Insert Shift:=xlToRight
For i = 2 to MyTableCount
' XLSheet.Range("Y"&i).Formula = "=Hyperlink(X"&i&")" 'This Excel formula changes the Text in column X to a hyper link in Column Y
' It used to work, but now it doesn't so I tried the line below; that didn't work either.
XLSheet.Range("Y"&i).Formula = "=Hyperlink("&Range("X"&i).Value&")"
Next
' Now have to copy column Y onto itself, but use PasteSpecial to paste values, not references, then rename column and delete original X column
XLSheet.Range("Y1:Y"&MyTableCount).Copy
XLSheet.Range("Y1:Y"&MyTableCount).PasteSpecial xlPasteValues
XLSheet.Range("Y1").Formula = "IMAGE" ' Restore the column name
XLSheet.Columns("X:X").Delete xlToLeft ' Delete the original IMAGE column
XLApp.Close True
End Sub[\code]
This used to work, but now doesn't. When I look at the new Excel file, the column that should be the links has the correct path, underlined in blue,
but it's not a hyperlink (and the cell doesn't contain the formula "=hyperlink(", just the path).
Any thoughts/tips? Thanks in advance for your help!