i have the error trapping to break on all errors as well.
That's not error handling. Its the responsibility of your sub to determine what should happen when an error occurs. Below is a template of my standard error handling. What error number you should put in your Case..Select is a matter of trial and error. 🙂
Sub Main()
On Error GoTo Err_Control
'Do your work here.
Cleanup:
Set oDwg = Nothing
Set oDbx = Nothing
Exit_Here:
Exit Sub
Err_Control:
Select Case Err.Number
'Add your Case selections here
'Case Is = 1000
'Handle error
'Err.Clear
'Resume Exit_Here
Case Else
MsgBox Err.Number & ", " & Err.Description, , "Main Title"
Err.Clear
Resume Exit_Here
End Select
End Sub
After some research, I found this in an MSDN article.
| Instead of |
LockWindowUpdate(hwnd) |
| Use |
SendMessage(hwnd, WM_SETREDRAW, FALSE, 0) or SetWindowRedraw(hwnd, FALSE) |
| Instead of |
LockWindowUpdate(NULL) |
| Use |
SendMessage(hwnd, WM_SETREDRAW, TRUE, 0) or SetWindowRedraw(hwnd, TRUE) |
As we noted earlier, only one window in the system can be locked for update at a time. If your intention for calling LockWindowUpdate is merely to prevent a window from redrawing, say, because you're updating it and don't want the window continuously refreshing until your update is complete, then just disable redraw on that window. If you use LockWindowUpdate, you create a whole slew of subtle problems.
So...
Public Const WM_SETREDRAW = &HB
Declare PtrSafe Function SendMessage Lib "user32" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
'Lock window redraw
SendMessage(oDoc.HWND, WM_SETREDRAW, FALSE, 0)
'Do work here
'Reset window redraw
SendMessage(oDoc.HWND, WM_SETREDRAW, TRUE, 0)
Ed
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to
post your code.