2009-07-28 10 views

答えて

2

できません。

避けようとしているシナリオの種類によっては、内容を何らかの形で暗号化することで、プロパティを"obfuscate"にすることができます。そうすれば、ユーザーは何かを有用なものに変える方法を見つけ出すのが難しくなりますが、ユーザーがそれを「壊す」ことを止めることはできません。

0

ドキュメントプロパティを使用する代わりに、(http://msdn.microsoft.com/en-us/library/bb212231.aspx)のドキュメント変数を使用してください。コードを介してのみアクセスできます。それらのためのUIはありません。

ここで私は彼らのために使用されるいくつかの古いVB6/VBA関数です:

Public Sub SetVariable(oDocument As Word.Document, sName As String, sValue As String) 

     Dim oVariable As Word.Variable 

     Set oVariable = LocateVariable(oDocument, sName) 

     If Not oVariable Is Nothing Then 

      oVariable.Value = sValue 

     Else 

      oDocument.Variables.Add sName, sValue 

     End If 

End Sub 

Public Function GetVariable(oDocument As Word.Document, sName As String) As String 

     Dim oVariable As Word.Variable 

     Set oVariable = LocateVariable(oDocument, sName) 

     If Not oVariable Is Nothing Then 

      GetVariable = oVariable.Value 

     Else 

      GetVariable = "" 

     End If 

End Function 

Public Function LocateVariable(oDocument As Word.Document, sName As String) As Word.Variable 

     Dim oVariable As Word.Variable 

     For Each oVariable In oDocument.Variables 

      If StrComp(oVariable.Name, sName, vbTextCompare) = 0 Then 

       Set LocateVariable = oVariable 

       Exit Function 

      End If 

     Next 

     Set LocateVariable = Nothing 

End Function 
関連する問題