Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
Hi,
Can you attach sample file and expected result, it helps in providing solution easily.
Regards,
Jagan.
I want to read the values of the fields of the sheet object CH01
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
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.
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
It is working.
Thank you very much
Michael how can i read the other fields also ?
I can not understand the code.
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