Check the current document count : Documents « Word « VBA / Excel / Access / Word






Check the current document count

 
Sub box()
  If Documents.Count = 0 Then
      Proceed = MsgBox("no document.Please open a document.", vbOKCancel + vbExclamation, "Format Report")
      If Proceed = vbOK Then
          Dialogs(wdDialogFileOpen).Show
          If Documents.Count = 0 Then End
      Else
          End
      End If
  End If
End Sub

 








Related examples in the same category

1.Loop through the Documents
2.Changes all bold formatting in the open document named Example.doc to italic formatting.
3.To maximize, minimize, or "restore" a window, set its WindowState property to wdWindowStateMaximize, wdWindowStateMinimize, or wdWindowStateNormal, respectively