Consulting

Results 1 to 5 of 5

Thread: Solved: help,about use 2 vba at the same time

  1. #1

    Solved: help,about use 2 vba at the same time

    how can i put the following 2 vba together, so when the workbook expired or over the limited, it will be deleted from the system?
    1.
    [VBA]
    Option Explicit
    Sub KillMe()
    With ThisWorkbook
    .Saved = True
    .ChangeFileAccess
    Mode:=xlReadOnly
    Kill .FullName .Close False
    End With
    End Sub
    [/VBA]
    2.
    [VBA]
    Private Sub Workbook_Open()
    Dim incRange As Range
    Dim StartDate As Date
    Set incRange = Range("Increment")
    StartDate = "19/06/06" 'Date delivered to customer
    Sheets("hidden").Visible = xlVeryHidden
    incRange = incRange + 1
    Me.Save
    If incRange > 10 Or Date - StartDate > 14 Then
    Application.DisplayAlerts = False
    MsgBox "over the use limit, contact owner"
    Me.Close
    End If
    End Sub
    [/VBA]

    thanx

  2. #2
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    What about any data the user may have put into your trial workbook - what's going to happen to that?
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  3. #3

    reply

    all data they put in already save as to other file names, this is only to the original workbook.


    Quote Originally Posted by johnske
    What about any data the user may have put into your trial workbook - what's going to happen to that?

  4. #4
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    [VBA]
    Option Explicit
    '
    Private Sub Workbook_Open()
    Dim incRange As Range
    Dim StartDate As Date
    Set incRange = Range("Increment")
    StartDate = "19/06/06" 'Date delivered to customer
    Sheets("hidden").Visible = xlVeryHidden
    incRange = incRange + 1
    Me.Save
    If incRange > 10 Or Date - StartDate > 14 Then
    Application.DisplayAlerts = False
    MsgBox "over the use limit, contact owner"
    KillMe
    End If
    End Sub
    '
    Sub KillMe()
    With ThisWorkbook
    .Saved = True
    .ChangeFileAccess Mode:=xlReadOnly
    Kill .FullName
    .Close False
    End With
    End Sub
    [/VBA]
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  5. #5
    thank you very much, it works perfectly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •