1

以前、私はこれを使用しました:

Private Sub Document_Close()
    Me.Saved = True
End Sub

Word文書を終了し、変更が加えられたときに保存プロンプトを無効にしますが、「コンボボックス(ActiveXコントロール)」を追加したので、Wordは再度保存を求めるプロンプトを表示します。これを回避する方法はありますか?

ドキュメントが閉じたときにコンボボックスを削除するコードを書いてみましたが、ボックスは使用後に自動的に削除され(私のコードではなく、単に削除されます)、ドキュメントを閉じるとボックスが存在せず、エラーが発生しますそこの。if present / error controlを実行することもできますが、根本的な問題を見つけるのではなく、だらしなくなっているように感じます...誰か助けてもらえますか?

4

1 に答える 1

1

同じ問題が発生し、Bingで解決策が見つかった場合:http: //answers.microsoft.com/en-us/office/forum/office_2007-customize/activex-control-blocks-ms-word-vba/71eca664-8e43 -4e4f-84c5-59154661ee5a

次のコードは、この問題を回避するのに役立ちました。

Dim WithEvents App As Application

Private Sub App_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
  'Did the user saved our file?
  If Not ThisDocument.Saved Then
    'Close our file?
    If Doc.Name = ThisDocument.Name Then
      'Cancel the dialog always!
      Cancel = True
      'Set the save state
      ThisDocument.Saved = True
      'Close the document after this event
      Application.OnTime Now + TimeSerial(0, 0, 1), Me.CodeName & ".Document_AfterClose"
    End If
  End If
End Sub

Sub Document_AfterClose()
  'Close the document without saving
  ThisDocument.Close False
End Sub

Private Sub cboEquip_Change()
  'Let the document know that a change is made
  ThisDocument.Saved = False
End Sub

Private Sub Document_Open()
  Set App = Application
End Sub
于 2013-02-25T15:47:51.123 に答える