R
Robert_L_Ross
I've got a weird situation that I'm tring to handle.
I have a 'cover sheet' .dot that we want to use to gather information,
display it properly (some values as bar codes, etc.) then close. We do NOT
want our users to be able to save the document (it contains vital data) and
we want control over the printing. We initially tried using buttons to print
(so as to not allow the file to be sent to a .pdf, etc.) but the problem with
the document was we used buttons. After reading around the newsgroups here,
I figured that actually making a toolbar for the .dot was the best solution.
I'm trying to make this document be as unobtrusive as possible, so I want to
gather the status of the toolbars at document open, store them so when the
user closes the document, the toolbars they originally had open will reappear.
After reading around, here's what I came up with. In the Document, I have a
Public declare area:
'Set Public Variables for Default Toolbars
Public toolbarSTANDARD, ... toolbarWORD_COUNT, toolbarWORDART As String
(It's really long...can I use the underscore to make this easier to read?)
I then set all of those values to False every time the document is opened
(in case they try to open multiple instances):
Public Sub Document_New()
'Set Public Variables for Default Toolbars to False (Clear Previous Values)
toolbarSTANDARD = False
toolbarFORMATTING = False
....etc.
I then get the current status and assign it to my public variables:
'Set Opening Toolbar Status for all Default Toolbars
If CommandBars("STANDARD").Visible = True Then
toolbarSTANDARD = True
End If
If CommandBars("FORMATTING").Visible = True Then
toolbarFORMATTING = True
End If
....etc.
I display a quick test message to verify the values were captured:
msg = MsgBox("STANDARD = " & toolbarSTANDARD & Chr(13) & Chr(10) & _
"FORMATTING = " & toolbarFORMATTING & Chr(13) & Chr(10) & _
...etc.
"WORDART = " & toolbarWORDART, vbOKOnly, "Toolbar Status")
I then close the toolbars:
'Close Default Toolbars
With CommandBars("Standard")
.Visible = False
End With
With CommandBars("Formatting")
.Visible = False
End With
...etc.
I then run my code that gathers the data and populates the fields on my forms:
Application.Run ("NewSheet")
End Sub
Everything works great - Until I try to close the form.
I have a message to state my 'public' stored values:
Public Sub Document_Close()
msg = MsgBox("STANDARD = " & toolbarSTANDARD & Chr(13) & Chr(10) & _
"FORMATTING = " & toolbarFORMATTING & Chr(13) & Chr(10) & _
...etc.
"WORDART = " & toolbarWORDART, vbOKOnly, "Toolbar Status")
At this point, all fields show as empty.
If I can retain my values, the code would go on to restore the toolbars.
Can someone tell me where I'm going wrong? I'm guessing I'm somehow
clearing the public variables somewhere, but I can't figure out where I'm
doing it.
Thanks in advance guys!
I have a 'cover sheet' .dot that we want to use to gather information,
display it properly (some values as bar codes, etc.) then close. We do NOT
want our users to be able to save the document (it contains vital data) and
we want control over the printing. We initially tried using buttons to print
(so as to not allow the file to be sent to a .pdf, etc.) but the problem with
the document was we used buttons. After reading around the newsgroups here,
I figured that actually making a toolbar for the .dot was the best solution.
I'm trying to make this document be as unobtrusive as possible, so I want to
gather the status of the toolbars at document open, store them so when the
user closes the document, the toolbars they originally had open will reappear.
After reading around, here's what I came up with. In the Document, I have a
Public declare area:
'Set Public Variables for Default Toolbars
Public toolbarSTANDARD, ... toolbarWORD_COUNT, toolbarWORDART As String
(It's really long...can I use the underscore to make this easier to read?)
I then set all of those values to False every time the document is opened
(in case they try to open multiple instances):
Public Sub Document_New()
'Set Public Variables for Default Toolbars to False (Clear Previous Values)
toolbarSTANDARD = False
toolbarFORMATTING = False
....etc.
I then get the current status and assign it to my public variables:
'Set Opening Toolbar Status for all Default Toolbars
If CommandBars("STANDARD").Visible = True Then
toolbarSTANDARD = True
End If
If CommandBars("FORMATTING").Visible = True Then
toolbarFORMATTING = True
End If
....etc.
I display a quick test message to verify the values were captured:
msg = MsgBox("STANDARD = " & toolbarSTANDARD & Chr(13) & Chr(10) & _
"FORMATTING = " & toolbarFORMATTING & Chr(13) & Chr(10) & _
...etc.
"WORDART = " & toolbarWORDART, vbOKOnly, "Toolbar Status")
I then close the toolbars:
'Close Default Toolbars
With CommandBars("Standard")
.Visible = False
End With
With CommandBars("Formatting")
.Visible = False
End With
...etc.
I then run my code that gathers the data and populates the fields on my forms:
Application.Run ("NewSheet")
End Sub
Everything works great - Until I try to close the form.
I have a message to state my 'public' stored values:
Public Sub Document_Close()
msg = MsgBox("STANDARD = " & toolbarSTANDARD & Chr(13) & Chr(10) & _
"FORMATTING = " & toolbarFORMATTING & Chr(13) & Chr(10) & _
...etc.
"WORDART = " & toolbarWORDART, vbOKOnly, "Toolbar Status")
At this point, all fields show as empty.
If I can retain my values, the code would go on to restore the toolbars.
Can someone tell me where I'm going wrong? I'm guessing I'm somehow
clearing the public variables somewhere, but I can't figure out where I'm
doing it.
Thanks in advance guys!