Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to add elements of array to listbox created by macros

Hi Community,

I am looking forward to add names array to listbox created.

please its urgent requirement to be fulfilled

Point to be noted: I dont have any sort of field by the name "names" in qvw

sub irf1

Dim names(100)

Set objExcel = CreateObject("Excel.Application")

'Msgbox("Hi")

Set objWorkbook = objExcel.Workbooks.Open _

    ("C:\Employee.xls")

    msgbox("Hello")

    rowcount =2

  Do Until objExcel.Cells(rowcount,1).Value = ""   

    names(rowcount-2)=objExcel.Cells(rowcount, 1).Value

   ' msgbox(names(rowcount-2))

'   

'   msgbox(objExcel.Cells(rowcount, 1).Value)

   rowcount = rowcount + 1

'

Loop

set LB = ActiveDocument.ActiveSheet.CreateListBox

set BoxProp=LB.GetProperties

BoxProp.Def.Name = "names"

LB.SetProperties BoxProp

end sub

5 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You can't populate listbox data using a macro. Even if you could, the data would not be connected to anything so would be of limited use.

Could you describe what overall problem you are trying to solve and maybe we can suggest some alternatives?

-Rob

Not applicable
Author

Hi Rob,

I am looking forward to  fetch the data from excel sheet on single click on button and syn. with other existing data.

I mean if I select data say EmpID which is fetch from excel sheet via action button then it should have to have association with other existing data too.

Please find the attached files.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

I am afraid that your example does not explain why you don't just load the data in the load script.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi Jonathan,

Yes I can do that,but i want the application should be user friendly to end user,So He/She can add data via action button. Can you help me out in the way I am looking forward to solve this issue.

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Then create a macro sub:

Sub Reload

     ActiveDocument.Reload

End Sub

And create an action button to call the macro. Or simpler still, train the users to use the reload button from the desktop client.

Bear in mind that user reloads can create all sorts of problems.

Regards

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein