Consulting

Results 1 to 2 of 2

Thread: Export to Excel clt: Disable worksheet event

  1. #1

    Export to Excel clt: Disable worksheet event

    Hello
    I have an excel.xlt file that has a worksheet event procedure
    [VBA]Public sCellAdd As String
    Public iPic As Integer
    Public sCell As String
    Public iRow As Integer
    Dim windowWidth As Double, widthOffset As Double
    Dim windowHeight As Double, heightOffset As Double

    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    Application.ScreenUpdating = False
    If InRange(Target, Range("Board")) Then
    On Error Resume Next
    ActiveSheet.Range("G" & sCell).Select
    Sheets("ClientDetails").Shapes("Pic1").Copy
    Sheets("Sheet1").PasteSpecial Format:="Picture (GIF)", Link:=False, _
    DisplayAsIcon:=False

    With ActiveWindow
    If 1 < .VisibleRange.Column Then
    widthOffset = Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(1, .VisibleRange.Column - 1)).Width
    End If
    If 1 < .VisibleRange.Row Then
    heightOffset = Range(ActiveSheet.Cells(1, 1), ActiveSheet.Cells(.VisibleRange.Row + 1, 1)).Height
    End If

    windowWidth = .UsableWidth
    windowHeight = .UsableHeight

    End With

    ActiveSheet.Shapes.Select
    With Selection
    .Top = ((windowHeight - .Height) / 2) + heightOffset
    .Left = ((windowWidth - .Width) / 2) + widthOffset
    End With
    ' ActiveSheet.Buttons.Add(467, ((windowHeight - Height) / 2) + heightOffset, 35.25, 16.5).Select
    ActiveSheet.Buttons.Add(537, ((windowHeight - Height - 325) / 2) + heightOffset, 35.25, 16.5).Select
    Selection.OnAction = "DeleteShapes"
    ActiveSheet.Shapes("Button 5").Characters.Text = "Close"
    Selection.Characters.Text = "Close"
    Cells(sCell, 3).Select

    End If
    Application.ScreenUpdating = True
    End Sub

    Private Function InRange(rng1, rng2) As Boolean
    ' Returns True if rng1 is a subset of rng2 InRange = False
    If rng1.Parent.Parent.Name = rng2.Parent.Parent.Name Then
    If rng1.Parent.Name = rng2.Parent.Name Then
    If Union(rng1, rng2).Address = rng2.Address Then
    InRange = True
    ' iRow = (Cells(rng1, rng2))
    ' iRow = rng1 + 3
    iCellAdd = rng1.Value
    Sheets("ClientDetails").Range("B2") = iCellAdd
    sCell = rng1.Row
    End If
    End If
    End If
    End Function[/VBA]

    The problem is that I want to disable this/comment it out, because I do not want it run yet, only when I'm finished.. can anyone help, thanking you

  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    The problem is that I want to disable this/comment it out, because I do not want it run yet
    You've answered your own question- just select all of the text and then click on the Comment Block button on the Edit Toolbar- this will comment out everything you selected.
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


Posting Permissions

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