+ Reply to Thread
Results 1 to 2 of 2

Adding "WorkbookOpen" Code Programmatically

  1. #1
    tyasm@hotmail.com
    Guest

    Adding "WorkbookOpen" Code Programmatically

    I'm trying to, I suppose for want of a better description, paste a
    WorbookOpen sub-routine into 'ThisWorkbook' component of a project in a
    new workbook.

    Basically I use shell files that refresh data from Access/Oracle
    tables, add any necessary formatting, then copy an array of sheets to a
    new workbook. I have since created some additional code that allows me
    to track who opens these final reports and the frequency.

    I have no trouble importing my .bas file, however adding the code to
    ThisWorkbook to call the sub-routine on WorkbookOpen is causing issues.

    Can anyone assist?

    MT


  2. #2
    Bob Phillips
    Guest

    Re: Adding "WorkbookOpen" Code Programmatically

    A simple example

    '----------------------------------------------------------------
    Sub AddWorkbookEventProc()
    '----------------------------------------------------------------
    Dim StartLine As Long

    With ActiveWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
    StartLine = .CreateEventProc("Open", "Workbook") + 1
    .InsertLines StartLine, _
    "Dim ans" & vbCrLf & _
    " ans = Msgbox( ""All OK"",vbYesNo)" & vbCrLf & _
    " If ans = vbNo Then myVar = True"
    End With

    End Sub



    --
    HTH

    Bob Phillips

    (remove xxx from email address if mailing direct)

    <tyasm@hotmail.com> wrote in message
    news:1147667090.085688.313340@u72g2000cwu.googlegroups.com...
    > I'm trying to, I suppose for want of a better description, paste a
    > WorbookOpen sub-routine into 'ThisWorkbook' component of a project in a
    > new workbook.
    >
    > Basically I use shell files that refresh data from Access/Oracle
    > tables, add any necessary formatting, then copy an array of sheets to a
    > new workbook. I have since created some additional code that allows me
    > to track who opens these final reports and the frequency.
    >
    > I have no trouble importing my .bas file, however adding the code to
    > ThisWorkbook to call the sub-routine on WorkbookOpen is causing issues.
    >
    > Can anyone assist?
    >
    > MT
    >




+ 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