Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to paste from Clipboard to Qlikview variable

Hi

  Can anybody help me write a macro to paste a string/number from Clipboard to QV variable.

Thanks

Abhishek

3 Replies
m_woolf
Master II
Master II

A little Internet research hints that vbscript can't access the clipboard directly.

A suggestion is to use an application (Excel?) to paste from the clipbaord.

Then store the value into the QlikView variable.

Not applicable
Author

Thanks for the suggestion.

I am currently using excel only. But when I use excel , I need to perform a reload to get the results back to Qlikview.

Can we copy data from excel to a Qlikview variable using Macro?

Thanks in advance for the solution.

m_woolf
Master II
Master II

sub ClipboardToVariable

  Set XLApp = CreateObject("Excel.Application")

  XLApp.Visible = False 

  Set XLWorkbook = XLApp.Workbooks.Add

  Set XLSheet1 = XLWorkbook.sheets("Sheet1")

  XLSheet1.select

  XLSheet1.Range("A1").select

  on error resume next

  XLSheet1.Paste

  set v = ActiveDocument.Variables("vFromClipboard")  'Replace vFromClipboard with your QlikView variable name

  v.SetContent XLSheet1.Range("A1").value,True

  XLWorkbook.Close False

  set XLSheet = nothing

  set XLWorkbook = nothing

  XLApp.Quit

  set XLApp = nothing

  set v = nothing

end sub