Here is the macro which closes all designers and leaves text files opened:
Sub CloseAllDesigners()
Dim doc As Document
For Each doc In DTE.Documents
Dim win As Window
For Each win In doc.Windows
Select Case TypeName(win.Object)
Case "TextWindow", "HTMLWindow"
'keep opened
Case Else
'close
win.Close(vsSaveChanges.vsSaveChangesPrompt)
End Select
Next
Next
End Sub
See my quick tutorial how to create and execute VS macro and assign a keybord shortcut or button to it. You can even automatically execute this macro before each build. In the Macros IDE Class View navigate to MyMacros - EnvironmentEvents. Open (double-click) EnvironmentEvents. Insert the following code inside module:
Private Sub BuildEvents_OnBuildBegin( _
ByVal Scope As EnvDTE.vsBuildScope, _
ByVal Action As EnvDTE.vsBuildAction) _
Handles BuildEvents.OnBuildBegin
CloseAllDesigners()
End Sub