1

すべてのプロジェクトをプロジェクトグループに追加し、それらのプロジェクトの各コンポーネントを反復処理し、フォームまたはユーザーコントロールが見つかった場合はそのプロパティを変更するVB6アドインがあります。

プロパティはユーザーが定義します。ユーザーがすべてのフォームまたはユーザーコントロールの高さを変更したい場合、コードスニペットは次のようになります

Private Sub Update_ButtonClick()
  '..declaring all the variables here

  ' VBInstance is initialized to VBIDE.VBE when the add-in is loaded

  For Index = 1 To projCount
    compoCount = VBInstance.VBProjects(Index).VBComponents.Count
    For jIndex = 1 To compoCount

      csFileName = VBInstance.VBProjects(Index).VBComponents(jIndex).name
      componentType = VBInstance.VBProjects(Index).VBComponents(jIndex).Type

      If componentType = VBIDE.vbext_ct_VBForm Or componentType = VBIDE.vbext_ct_UserControl Then '.frm or .ctl         
        VBInstance.VBProjects(Index).VBComponents(jIndex).Properties(propChange).Value = propvalue 'changing the property
        VBInstance.VBProjects(Index).VBComponents(jIndex).SaveAs csFileName 'Saving the file
      End If
    Next jIndex
  Next Index
End Sub

プロパティ名をとして指定Fontすると、エラーが発生します

ランタイムエラー「425」オブジェクトの使用が無効です

http://visualbasic.freetutes.com/learn-vb6-advanced/lesson13/p20.htmlPropertyBag.WritePropertyから試しましたが、目的を果たしていません。

Fontコントロールまたはフォームのプロパティを設定する方法はありますか?

メモ帳でctlまたはformを開くと、プロパティが見つからないため、Fontここでテキスト置換を使用できません。

誰か助けてもらえますか?

更新されたコード:


Private Sub Update_ButtonClick()
    Dim fobject As New StdFont
    fobject.Name = "Arial"
    Set propvalue = fobject
    For Index = 1 To projCount
     compoCount = VBInstance.VBProjects(Index).VBComponents.Count
     For jIndex = 1 To compoCount
      csFileName = VBInstance.VBProjects(Index).VBComponents(jIndex).Name
      componentType = VBInstance.VBProjects(Index).VBComponents(jIndex).Type
      If componentType = 5 Or componentType = 8 Then 
       VBInstance.VBProjects(Index).VBComponents(jIndex).Properties("Font").Value=  propvalue
      VBInstance.VBProjects(Index).VBComponents(jIndex).SaveAs csFileName 
      End If
       Next jIndex
     Next Index 
End Sub

そして、私が得たエラーは

Run-time error '425':
Invalid object use
4

1 に答える 1

5

Fontプロパティはオブジェクトであり、単純な本質的価値ではありません。Setに割り当てられた適切なStdFontオブジェクトで使用する必要がありますpropvalue

または、フォントを特殊なケースに分けて、プロパティの.Nameプロパティを必要なフォント名に設定することもできます。

于 2013-01-04T10:16:08.480 に答える