Consulting

Results 1 to 3 of 3

Thread: Solved: Trust Access To... question

  1. #1
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location

    Solved: Trust Access To... question

    I only have Office 2k so I can't test this myself... What I want to know is in 2002 and up, if the 'Trust Access to Visual Basic Project' is left unchecked, will using late binding allow this code (specifically) to run?

    Note: Caution!! This deletes ALL VBA code in the workbook[vba]
    Sub DeleteAllVBA()
    'use late binding so no reference is needed
    Dim Component As Object
    For Each Component In ThisWorkbook.VBProject.VBComponents
    Select Case Component.Type
    Case 1, 2, 3
    ThisWorkbook.VBProject.VBComponents.Remove Component
    Case Else
    With Component.CodeModule
    .DeleteLines 1, .CountOfLines
    End With
    End Select
    Next
    End Sub
    [/vba]TIA,
    John
    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.

  2. #2
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    Nope. Works fine with the box checked, but errors if the box is unchecked.

    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  3. #3
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    OK, thanx Ken (that's what I thought )
    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.

Posting Permissions

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