V
VBA Coder
Does anyone know why the creation of a PopUp MenuBar would cause the "Save
As" dialog box to appear?
I have a UserForm that loads when a user create a new document based on a
Template file. The UserForm allows the user to enter criteria that will
populate bookmarks and add tables and text to the document. On this
UserForm I created a "Hide" button, that allows the user to Hide the Form so
that they can switch over to the document to make changes. Because Word97
makes all UserForms modal, there was no way to allow the user to work on the
document without closing the UserForm. However, the users need to keep this
form loaded so that they can make additional changes on the UserForm which
will in turn update the document. So the "Hide" button method was created.
When the user clicks the "Hide" button, I created a PopUp menu that has a
button on it that allows them to "Show" the UserForm so that when they've
made all their changes to the document, they can come back to the UserForm.
It is this PopUp Command Bar that is causing Word to think the Template has
changed, therefore, prompting the user to "Save" the template file (.dot)
when they close their Document (.doc). I have made the Command Bar
"Temporary", so that it is not part of the Template. Any ideas why this may
be causing Word to think the Template has changed? I have even tried using
the ActiveDocument.AttachedTemplate.Saved =True, with no success. As long
as the user clicks the btnHide, which loads this CommandBar, the user will
always get the "Save As" dialog box on the Template file when they close
their document. My code is below:
Private Sub btnHide_Click()
' Hide the UserForm
frmMacroMain.Hide
' Show the PopUp Form Button to allow the user to Re-Show the form
ShowPopUpFormButton
End Sub
Public Function ShowPopUpFormButton()
Dim myBar As CommandBar
Dim graphBtn As CommandBarButton
Dim bFound As Boolean, sToolBarName As String
sToolBarName = "ShowMacroForm"
' Check if the PopUp Form already exists. If so, just show it, otherwise,
create it
For Each myBar In CommandBars
If Left$(myBar.Name, Len(sToolBarName)) = sToolBarName Then
bFound = True
Exit For
End If
Next
If bFound Then
CommandBars(sToolBarName).Visible = True
Else
Set myBar = CommandBars.Add(Name:=sToolBarName,
Position:=msoBarFloating, _
Temporary:=True)
myBar.Visible = True
Set graphBtn = myBar.Controls.Add(Type:=msoControlButton)
With graphBtn
.Caption = "&Show Form"
.Style = msoButtonCaption
.DescriptionText = "&Show Macro Form"
' When clicked, run the Macro to Show the Form
.OnAction = "ShowMacroForm"
End With
End If
End Function
As" dialog box to appear?
I have a UserForm that loads when a user create a new document based on a
Template file. The UserForm allows the user to enter criteria that will
populate bookmarks and add tables and text to the document. On this
UserForm I created a "Hide" button, that allows the user to Hide the Form so
that they can switch over to the document to make changes. Because Word97
makes all UserForms modal, there was no way to allow the user to work on the
document without closing the UserForm. However, the users need to keep this
form loaded so that they can make additional changes on the UserForm which
will in turn update the document. So the "Hide" button method was created.
When the user clicks the "Hide" button, I created a PopUp menu that has a
button on it that allows them to "Show" the UserForm so that when they've
made all their changes to the document, they can come back to the UserForm.
It is this PopUp Command Bar that is causing Word to think the Template has
changed, therefore, prompting the user to "Save" the template file (.dot)
when they close their Document (.doc). I have made the Command Bar
"Temporary", so that it is not part of the Template. Any ideas why this may
be causing Word to think the Template has changed? I have even tried using
the ActiveDocument.AttachedTemplate.Saved =True, with no success. As long
as the user clicks the btnHide, which loads this CommandBar, the user will
always get the "Save As" dialog box on the Template file when they close
their document. My code is below:
Private Sub btnHide_Click()
' Hide the UserForm
frmMacroMain.Hide
' Show the PopUp Form Button to allow the user to Re-Show the form
ShowPopUpFormButton
End Sub
Public Function ShowPopUpFormButton()
Dim myBar As CommandBar
Dim graphBtn As CommandBarButton
Dim bFound As Boolean, sToolBarName As String
sToolBarName = "ShowMacroForm"
' Check if the PopUp Form already exists. If so, just show it, otherwise,
create it
For Each myBar In CommandBars
If Left$(myBar.Name, Len(sToolBarName)) = sToolBarName Then
bFound = True
Exit For
End If
Next
If bFound Then
CommandBars(sToolBarName).Visible = True
Else
Set myBar = CommandBars.Add(Name:=sToolBarName,
Position:=msoBarFloating, _
Temporary:=True)
myBar.Visible = True
Set graphBtn = myBar.Controls.Add(Type:=msoControlButton)
With graphBtn
.Caption = "&Show Form"
.Style = msoButtonCaption
.DescriptionText = "&Show Macro Form"
' When clicked, run the Macro to Show the Form
.OnAction = "ShowMacroForm"
End With
End If
End Function