code to run only once and never again

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geradmcginty
    New Member
    • May 2014
    • 1

    code to run only once and never again

    Forgive me in advance, but I have a word.dot that inserts a unique receipt number sequentially into the header of the document on open, trouble is when ever someone else opens the doc it runs again and overwrites the originally created number with a new one, I’ll need the syntax version, I thought of using the system date and time but the following is as far as I got
    Code:
     
    Private Sub Document_Open()  
        Dim FRun As String
        Dim LRun As String
            FRun = Now
         LRun = Now
                If LRun = FRun Then
            ‘run my code
                MsgBox (" Times are equal ") & FRun & LRun
                'run some code
               End If
            ‘don’t run code
            MsgBox (" Times are not equal ") & FRun & LRun
    End Sub
Working...