+ Reply to Thread
Results 1 to 7 of 7

continue code

Hybrid View

  1. #1
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    If you are halting your code to allow user intervention you will need to alter your code to take this into account.

    You can use a public variable to store the state of the macro execution.

    This is only pseudo code.
    Public g_blnMacroRunning as boolean
    
    Sub MyCode()
    
       if not g_blnMacroRunning then
    
          ' do first part of macro
          
          g_blnMacroRunning = True
    
          ' Left user do his thing
          Exit sub
       endif
    
       g_blnMacroRunning = False
    
       ' do second part of macro
    
    End sub
    If you need more help you will need to, as Dave points out, provide more information.
    Cheers
    Andy
    www.andypope.info

  2. #2
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    thanks for the response guys
    here is the code
    Sub PRINTSUPPLYONLY()
        Select Case _
               MsgBox("HAVE YOU SELECTED THE SYSTEM IN THE DELIVERY SHEET?", _
                      vbYesNo Or vbQuestion Or vbDefaultButton1, "Delivery sheet")
              
            Case vbYes
      Sheets("Delivery note").Select
                MsgBox "PLEASE INSERT 1 SHEET OF HEADED PAPER!"
                Sheets("Receipt of deposit letter").Select
                ExecuteExcel4Macro "PRINT(1,,,2,,,,,,,,2,,,TRUE,,FALSE)"
                Sheets("Job Sheet").Select
                ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
                Sheets("Delivery note").Select
                ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
            Case vbNo
    Sheets("Delivery note").Select
        Range("B16").Select
                Exit Sub
        End Select

  3. #3
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    bump bump bump please

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481
    Try this, although if the user may not have selected the system of delivery when the code is run for the second time.

    Is there no way you can check that the delivery system has been chosen?

    Private m_blnRunningMacro  As Boolean
    Sub PRINTSUPPLYONLY()
        
        Dim lngAns As VbMsgBoxResult
        
        If Not m_blnRunningMacro Then
        
            lngAns = MsgBox("HAVE YOU SELECTED THE SYSTEM IN THE DELIVERY SHEET?", _
                            vbYesNo Or vbQuestion Or vbDefaultButton1, "Delivery sheet")
        Else
            lngAns = vbYes
            m_blnRunningMacro = False
        End If
        
        Select Case lngAns
        Case vbYes
            Sheets("Delivery note").Select
            MsgBox "PLEASE INSERT 1 SHEET OF HEADED PAPER!"
            Sheets("Receipt of deposit letter").Select
            ExecuteExcel4Macro "PRINT(1,,,2,,,,,,,,2,,,TRUE,,FALSE)"
            Sheets("Job Sheet").Select
            ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
            Sheets("Delivery note").Select
            ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,,,TRUE,,FALSE)"
        Case vbNo
            Sheets("Delivery note").Select
            Range("B16").Select
                
            m_blnRunningMacro = True
            
            Exit Sub
        End Select
        
    End Sub

  5. #5
    Forum Contributor
    Join Date
    06-23-2007
    Posts
    690
    hi andy

    willc heck this when i get home
    thanks for the reply
    basically there are only a couple of users for this form so thats not really an issue

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1