Shape.SetResults メソッド (Visio)

1 つまたは複数のセルの結果や数式を設定します。

構文

expression. SetResults( _SRCStream()_ , _UnitsNamesOrCodes()_ , _resultArray()_ , _Flags_ )

: Shape オブジェクトを表す変数。

パラメーター

名前 必須 / オプション データ型 説明
SID_SRCStream() 必須 Integer 変更するセルを識別する配列です。
UnitsNamesOrCodes() 必須 バリアント型 結果の配列エントリに適用する単位です。
resultArray() 必須 バリアント型 出力パラメーターです。 識別されたセルに割り当てる結果または数式です。
Flags 必須 Integer SetResults の動作を制御するフラグです。

戻り値

整数

注釈

SetResults メソッドは Cell オブジェクトの Result メソッドに類似していますが、このメソッドでは一度に 1 つのセルではなく複数のセルの結果 (値) を設定できます。

Shape オブジェクトに対して SetResults メソッドを使用すると、セルの組み合わせに関する結果を設定できます。 SetResults メソッドで SID_SRCStream() に整数の配列を渡すことにより、設定するセルを指定します。 SID_SRCStream() は 2 バイトの整数で構成される 1 次元配列です。

Shape オブジェクトの場合、SID_SRCStream() は、n>= 1 の場合に 3 n 個の 2 バイト整数の 1 次元配列である必要があります。 SetResults メソッドはストリームを次のように解釈します。

{sectionIdx, rowIdx, cellIdx }n

この sectionIdx は、対象となるセルのセクション インデックスです。また rowIdx は、そのセルの行インデックスで、cellIdx は、そのセルのセル インデックスです。

UnitsNamesOrCodes() は、結果の個々のエントリの単位を制御する配列です。 この配列の各エントリには、"inches"、"inch"、"in"、"i" などの文字列が格納されます。 センチメートル、メートル、マイルなど、Visio がサポートしているすべての単位の文字列を使用できます。 VisUnitCodes の Visio タイプ ライブラリで宣言されている整数の定数 (visCentimetersvisInches など) を使用して、必要な単位を指定することもできます。 測定単位に使用される定数の一覧については、「 測定単位について」を参照してください。 FlagsvisSetFormulas が設定されている場合、UnitsNamesOrCodes() 配列に指定した値は無効になります。

UnitsNamesOrCodes() が空でない場合は、1 <= u 個のバリアントの 1 次元配列であることが想定されます。 各エントリは、文字列または整数のコード、または空 (何もない) にすることができます。 i 番目のエントリが空の場合、resultArrayi 番目のエントリは UnitsNamesOrCodes()(j) で指定された単位になります。ここで、j は空ではない最新の前のエントリです。 したがって、 resultArray のすべてのエントリを同じ単位で解釈したい場合は、1つのエントリを持つ UnitsNamesOrCodes() 配列を渡すだけで済みます。 空ではない前のエントリがない場合、または UnitsNamesOrCodes() 配列が指定されていない場合は、 visNumber (0x20) が使用されます。 これにより、アプリケーションは既定で内部単位になります (Cell オブジェクトの ResultIU プロパティと同様に)。

resultArray() パラメーターは、1 <= m 個のバリアントの 1 次元配列である必要があります。 結果は、 DoubleIntegerString、または String への参照として渡すことができます。 文字列は、 visSetFormulasFlags に設定されている場合にのみ受け入れられ、その場合、文字列は数式として解釈されます。 resultArray(i) が空の場合、i 番目のセルは resultArray(j) の値に設定されます (j は空ではない最新の前のエントリのインデックスです)。 空ではない前のエントリがない場合、対応するセルは変更されません。 指定された結果がセルよりも少ない場合 (m < n の場合)、i 番目のセル i < m は、m 番目のセルと同じ値に設定されます。 したがって、多くのセルを同じ値に設定するには、値のコピーを 1 つ渡すだけで済みます。

パラメーター Flags はビットマスクであり、次の値を指定できます。

定数 説明
visSetFormulas &H1 結果の文字列を数式として処理します。
visSetBlastGuards &H2 保護されている場合でも、現在のセルの値を上書きします。
visSetTestCircular &H4 循環セル参照の設定をテストします。
visSetUniversalSyntax &H8 数式を汎用構文で指定します。

SetResults メソッドによって返される値は、正常に処理された SID_SRCStream() 内のエントリの数を示します。 i < n 個のエントリが正しく処理されたが、i + 1 番目のエントリでエラーが発生した場合、SetResults メソッドは例外を発生させて i を返します。 それ以外の場合は、n が返されます。

次の例は、 SetResults メソッドの使用方法を示しています。 この例では、少なくとも 3 個の図形を含むアクティブ ページがあることが前提となっています。 GetResults メソッドを使用して図形 1 の幅、図形 2 の高さ、および図形 3 の角度を取得します。 次に 、SetResults を使用して、図形 1 の幅を図形 2 の高さに、図形 2 の高さを図形 1 の幅に設定します。図形 3 の角度は変更されません。

この例は、Page オブジェクトの GetResults メソッドを使用して 3 個のセル数式を取得し、同じオブジェクトの SetResults メソッドを使用して数式を設定します。 入力配列は、Master オブジェクトと同様に各セルの 4 個のスロットを持ちます。 Shape オブジェクトまたは Style オブジェクトに対しては、各セル (セクション、行、およびセル) に 3 個のスロットがあれば十分です。

 
Public Sub Set Results_Example() 
 
 On Error GoTo HandleError 
 
 Dim aintSheetSectionRowColumn(1 To (3 * 4)) As Integer 
 aintSheetSectionRowColumn(1) = ActivePage.Shapes(1).ID 
 aintSheetSectionRowColumn(2) = visSectionObject 
 aintSheetSectionRowColumn(3) = visRowXFormOut 
 aintSheetSectionRowColumn(4) = visXFormWidth 
 
 aintSheetSectionRowColumn(5) = ActivePage.Shapes(2).ID 
 aintSheetSectionRowColumn(6) = visSectionObject 
 aintSheetSectionRowColumn(7) = visRowXFormOut 
 aintSheetSectionRowColumn(8) = visXFormHeight 
 
 aintSheetSectionRowColumn(9) = ActivePage.Shapes(3).ID 
 aintSheetSectionRowColumn(10) = visSectionObject 
 aintSheetSectionRowColumn(11) = visRowXFormOut 
 aintSheetSectionRowColumn(12) = visXFormAngle 
 
 'Get the first two values in inches. The second element in 
 'the units array is left uninitialized (empty) because we 
 'want the second result in the same units as the first 
 'result. The third result is initialized in degrees. Note that 
 'units can be expressed as a string or an integer constant. 
 Dim avarUnits(1 To 3) As Variant 
 avarUnits(1) = "in." 
 avarUnits(3) = visDegrees 
 
 'Return results of cells as an array of floating point numbers. 
 Dim avarResults() As Variant 
 ActivePage.GetResults aintSheetSectionRowColumn, visGetFloats, _ 
 avarUnits, avarResults 
 
 'Use SetResults to: 
 
 ' - Set the width of shape 1 to the height of shape 2. 
 
 ' - Set the height of shape 2 to the width of shape 1. 
 
 'NOTE: avarResults() is indexed from 0 to 2. 
 
 Dim varTemp As variant 
 varTemp = avarResults(0) 
 avarResults(0) = avarResults(1) 
 avarResults(1) = varTemp 
 
 'Pass the same array back to SetResults that we 
 'just passed to GetResults, but leave the angle 
 'alone. By setting the sheet ID entry in the third 
 'slot of the aintSheetSectionRowColumn array to 
 'visInvalShapeID, we tell SetResults to ignore that slot. 
 aintSheetSectionRowColumn(9) = visInvalShapeID 
 
 'Set the results of the cells. 
 ActivePage.SetResults aintSheetSectionRowColumn, avarUnits, avarResults, 0 
 
 Exit Sub 
 
HandleError: 
 
 MsgBox "Error" 
 
 Exit Sub 
 
End Sub

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。