+ Reply to Thread
Results 1 to 2 of 2

Onkey gone haywire!!!

Hybrid View

  1. #1
    Registered User
    Join Date
    01-09-2007
    Posts
    12

    Onkey gone haywire!!!

    Hi,

    I am using the following macros and they work fine if I attach it to the f9 key or run them from the vb editor but if I attach it to the shift f9 key the macro stops after it opens the file????? This makes no sense to me!! Any help greatly appreciated

    
    Public Sub Workbook_Open()
    
    Application.OnKey key:="+{F9}", procedure:="RecalcShftF91"
    
    End Sub

    Public Sub RecalcShftF91() 'this occurs if they use Shift F9
    
    
    ' Checks whether a file exists
    
    Dim fso
    Dim file As String
    
    file = "\\Testing.txt" ' '  file & w/Path
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    
    ' Does the file exist?
    
    
    If Not fso.FileExists(file) Then
        
    GoTo Line1 'If the file doesn't exist
    
    Else 'if the file does exist
     
    Workbooks.OpenText Filename:="\\Testing.txt"
         
    
    ActiveWorkbook.Close
    
    
    End If
        
    Line1:
    
    
    End Sub
    Last edited by timatstockers; 05-19-2008 at 02:55 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Please edit your post by adding Code tags.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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