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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to read data from external file and pass those values to Qlikiew file

I am looking for Macro examples to accomplish the
below scenario

I have customer no from the excel or text file.
Customer.qvw file has customer relevant details.

We have to select the customerno from the external file(text or excel file) and pass the selected customerno to Customerno selection in the Customer.qvw (restrict only those selected customer in the Customer.qvw file).
Current selection - It suppose to show only selected customers from the file.

Advance thanks for your help.

3 Replies
Not applicable
Author

Here's an example using an Excel file:

Sub Excel_OLE_Automation
Set oXL=CreateObject("Excel.Application")
f_name=oXL.GetOpenFilename("All Files (*.*),*.*",,"Select file",False)
If f_name="False" then
'user cancelled out of dialog box
Set oXL=nothing
Exit sub
End If
Set oWB=oXL.Workbooks.Open(f_name)
Set oSH=oWB.Worksheets.Item(1)
xlVal = oSH.Range("A2")
ActiveDocument.Variables("vXLCust").SetContent xlVal, true
ActiveDocument.Fields("Customerno").Select xlVal
oWB.Close
Set oSH=nothing
Set oWB=nothing
Set oXL=nothing
End Sub


Not applicable
Author

I am getting the message

ActiveX component can't create object

Where do I need to set the file path for reading the file.(Select file)

It will be great - please provide me the qvw file.





Not applicable
Author

Are you running this as a plug-in or native client? I am not sure the Excel DOM will work in the plug-in.

You may also need to allow system access. In your macro window, set Requested Module Security to System Access and Current Local Security to Allow System Access.

I don't really have a QVW that demonstrates this. I modified a macro I created in the past. That QVW is just the macro and a button along with an Excel file.