【发布时间】:2018-12-15 05:05:04
【问题描述】:
当我在消息框提示中选择否时,文档仍会关闭。当我选择否时,我希望它保持打开状态。我不知道该怎么做。谢谢。
Option Explicit
Sub b()
'declares docX as a document and stores it
Dim docX As Documents
'opens the document file
Application.Documents.Open FileName:="C:\Users\johnr\OneDrive\Documents\CIS 208 VBA\Rimando_Input_Box.docm"
'prompts the user to select either Yes or No
MsgBox Prompt:="Close document?", _
Buttons:=vbYesNo
'If the user selects the Yes button then the document closes without making save changes.
If vbYes Then
Application.ActiveDocument.Close SaveChanges:=wdPromptToSaveChanges
Else
'Keep the document open
End If
End Sub
【问题讨论】: