PrestonWhitn
03-10-2010, 10:19 PM
I have a file that opens a form when the file is opened. That form inserts the field date into bookmarks in the document when the OK button is pressed. the form code is below and the document code is below that. The problem I am having is that when I try and close out the file it always errors and wont let me save the file with the updated fields. Any suggestions what I might be doing wrong.
Private Sub btnOK_Click()
Dim varModelNo As String
If opt800 = True Then varModelNo = "800"
If opt1800 = True Then varModelNo = "1800"
If opt3600 = True Then varModelNo = "3600"
If opt5400 = True Then varModelNo = "5400"
If opt7000 = True Then varModelNo = "7000"
If opt10000 = True Then varModelNo = "10000"
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("QuoteNo").Range.Text = txtQuoteNo.Value
.Bookmarks("RevNo").Range.Text = txtRevNo.Value
.Bookmarks("ClientName").Range.Text = txtClientName.Value
.Bookmarks("QuoteDateLong").Range.Text = txtQuoteDate.Value
.Bookmarks("PreparedBy").Range.Text = txtPreparedBy.Value
.Bookmarks("ModelNo").Range.Text = varModelNo
End With
Application.ScreenUpdating = True
Unload Me
End Sub
Private Sub UserForm_Initialize()
txtQuoteNo.Value = True
End Sub
Document Code
Private Sub Document_Open()
BioScruQuote.Show
End Sub
Private Sub btnOK_Click()
Dim varModelNo As String
If opt800 = True Then varModelNo = "800"
If opt1800 = True Then varModelNo = "1800"
If opt3600 = True Then varModelNo = "3600"
If opt5400 = True Then varModelNo = "5400"
If opt7000 = True Then varModelNo = "7000"
If opt10000 = True Then varModelNo = "10000"
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("QuoteNo").Range.Text = txtQuoteNo.Value
.Bookmarks("RevNo").Range.Text = txtRevNo.Value
.Bookmarks("ClientName").Range.Text = txtClientName.Value
.Bookmarks("QuoteDateLong").Range.Text = txtQuoteDate.Value
.Bookmarks("PreparedBy").Range.Text = txtPreparedBy.Value
.Bookmarks("ModelNo").Range.Text = varModelNo
End With
Application.ScreenUpdating = True
Unload Me
End Sub
Private Sub UserForm_Initialize()
txtQuoteNo.Value = True
End Sub
Document Code
Private Sub Document_Open()
BioScruQuote.Show
End Sub