Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
geogou1973
Creator
Creator

ActiveDocument.GetSheetObject("CH01") and read the fields

Hello.

How can i read the values of a field of a sheet object in a vbscript module ?

sub test

SET Doc = ActiveDocument.GetSheetObject("CH01")

set Field = Doc.Fields("STORE_ID").GetPossibleValues

FOR i=0 to Field.Count -1

Doc.Fields("STORE_ID").SELECT Field.Item(i).Text

msgbox(Field)

next

end sub

This script does not work.

Can anyone help me ?

Thank you in advance.

1 Solution

Accepted Solutions
Anonymous
Not applicable

Your macro reads field values, but you need to read from the chart directly.  Replace macro with this:

Sub TEST

set obj = ActiveDocument.GetSheetObject( "CH01" )
CellRect = ActiveDocument.GetApplication().GetEmptyRect()
CellRect.Top = 0
CellRect.Left = 0
CellRect.Width = obj.GetColumnCount
CellRect.Height = obj.GetRowCount
set CellMatrix = obj.GetCells( CellRect )
for RowIter=CellRect.Top+1 to CellRect.Height-1
        msgbox(CellMatrix(RowIter)(ColIter).Text)
next  
End sub

Regards,

Michael

View solution in original post

8 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

Can you attach sample file and expected result, it helps in providing solution easily.

Regards,

Jagan.

geogou1973
Creator
Creator
Author

I want to read the values of the fields of the sheet object CH01

giakoum
Partner - Master II
Partner - Master II

SUB ShowValues

set CntValues = ActiveDocument.fields("Activity1").getPossibleValues

  for i=0 to CntValues.Count - 1

  a = CntValues.Item(i).Text

  msgbox(a)

  next

end sub

geogou1973
Creator
Creator
Author

Sorry the file that i uploaded was not correct.

If you see the script reads all the values.

I want to read only the values that are in the chart.

Anonymous
Not applicable

Your macro reads field values, but you need to read from the chart directly.  Replace macro with this:

Sub TEST

set obj = ActiveDocument.GetSheetObject( "CH01" )
CellRect = ActiveDocument.GetApplication().GetEmptyRect()
CellRect.Top = 0
CellRect.Left = 0
CellRect.Width = obj.GetColumnCount
CellRect.Height = obj.GetRowCount
set CellMatrix = obj.GetCells( CellRect )
for RowIter=CellRect.Top+1 to CellRect.Height-1
        msgbox(CellMatrix(RowIter)(ColIter).Text)
next  
End sub

Regards,

Michael

geogou1973
Creator
Creator
Author

It is working.

Thank you very much

geogou1973
Creator
Creator
Author

Michael how can i read the other fields also ?

I can not understand the code.

Anonymous
Not applicable

The macro above is a slightly modified version of this one from the API Guide, which cycles through both rowns and columns, and starts from the header row:

set obj = ActiveDocument.GetSheetObject( "CH01" )

CellRect = ActiveDocument.GetApplication().GetEmptyRect()

CellRect.Top = 0

CellRect.Left = 0

CellRect.Width = obj.GetColumnCount

CellRect.Height = obj.GetRowCount

set CellMatrix = obj.GetCells( CellRect )

for RowIter=CellRect.Top to CellRect.Height-1

    for ColIter=CellRect.Left to CellRect.Width-1

        msgbox(CellMatrix(RowIter)(ColIter).Text)

    next

next

Open the API Guide, take a look.

Regards,

Michael