+ Reply to Thread
Results 1 to 4 of 4

VBA Stops Before competing the program

  1. #1
    ch
    Guest

    VBA Stops Before competing the program

    Hi Guys (that refers to all of you gurus out there) !!
    I have a VBA that goes as below.

    The program STOPS (not break) executing at the "Workbooks.Open" line when I
    assign it to short cut keys (eg Ctrl-Shift- T). There are several other
    command lines yet to be executed.

    It works fine if I create a command button and assign MainTouchUp() macro to
    the button.
    It also works fine if I go to the Visual Basic Editor and hit "F5" in the
    MainTouchUp() command lines.

    By the way, the MainTouchUp() and the ReadTouchUp() are in different user
    modules, not sure if this affects the program.

    Please help.


    =========================================
    Sub MainTouchUp()
    ...
    Call ReadTouchUp(FileToOpen)
    ...
    End Sub


    Sub ReadTouchUp(FileToOpen)
    Dim fs, f, s

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(FileToOpen)
    s = f.path

    Masterfile = ActiveWorkbook.Name

    STOPS AT THIS POINT : Workbooks.Open FileToOpen

    If Right(FileToOpen, 3) = "csv" Then
    Call ReadTouchUpCSV(s)
    ElseIf Right(FileToOpen, 3) = "txt" Then
    Call ReadTouchUpText
    End If
    End Sub
    =========================================


  2. #2
    Dave Peterson
    Guest

    Re: VBA Stops Before competing the program

    When you open a file and hold down the shift key, excel thinks you want to avoid
    the Auto_open and workbook_open procedures.

    If your shortcut key includes the shift key, then excel stops -- it's kind of
    confused.

    So if you remove the shift key from the shortcut key combination, things should
    be back to normal.

    ch wrote:
    >
    > Hi Guys (that refers to all of you gurus out there) !!
    > I have a VBA that goes as below.
    >
    > The program STOPS (not break) executing at the "Workbooks.Open" line when I
    > assign it to short cut keys (eg Ctrl-Shift- T). There are several other
    > command lines yet to be executed.
    >
    > It works fine if I create a command button and assign MainTouchUp() macro to
    > the button.
    > It also works fine if I go to the Visual Basic Editor and hit "F5" in the
    > MainTouchUp() command lines.
    >
    > By the way, the MainTouchUp() and the ReadTouchUp() are in different user
    > modules, not sure if this affects the program.
    >
    > Please help.
    >
    > =========================================
    > Sub MainTouchUp()
    > ...
    > Call ReadTouchUp(FileToOpen)
    > ...
    > End Sub
    >
    > Sub ReadTouchUp(FileToOpen)
    > Dim fs, f, s
    >
    > Set fs = CreateObject("Scripting.FileSystemObject")
    > Set f = fs.GetFile(FileToOpen)
    > s = f.path
    >
    > Masterfile = ActiveWorkbook.Name
    >
    > STOPS AT THIS POINT : Workbooks.Open FileToOpen
    >
    > If Right(FileToOpen, 3) = "csv" Then
    > Call ReadTouchUpCSV(s)
    > ElseIf Right(FileToOpen, 3) = "txt" Then
    > Call ReadTouchUpText
    > End If
    > End Sub
    > =========================================


    --

    Dave Peterson

  3. #3
    ch
    Guest

    Re: VBA Stops Before competing the program

    It worked. Thanks !


    "Dave Peterson" wrote:

    > When you open a file and hold down the shift key, excel thinks you want to avoid
    > the Auto_open and workbook_open procedures.
    >
    > If your shortcut key includes the shift key, then excel stops -- it's kind of
    > confused.
    >
    > So if you remove the shift key from the shortcut key combination, things should
    > be back to normal.
    >
    > ch wrote:
    > >
    > > Hi Guys (that refers to all of you gurus out there) !!
    > > I have a VBA that goes as below.
    > >
    > > The program STOPS (not break) executing at the "Workbooks.Open" line when I
    > > assign it to short cut keys (eg Ctrl-Shift- T). There are several other
    > > command lines yet to be executed.
    > >
    > > It works fine if I create a command button and assign MainTouchUp() macro to
    > > the button.
    > > It also works fine if I go to the Visual Basic Editor and hit "F5" in the
    > > MainTouchUp() command lines.
    > >
    > > By the way, the MainTouchUp() and the ReadTouchUp() are in different user
    > > modules, not sure if this affects the program.
    > >
    > > Please help.
    > >
    > > =========================================
    > > Sub MainTouchUp()
    > > ...
    > > Call ReadTouchUp(FileToOpen)
    > > ...
    > > End Sub
    > >
    > > Sub ReadTouchUp(FileToOpen)
    > > Dim fs, f, s
    > >
    > > Set fs = CreateObject("Scripting.FileSystemObject")
    > > Set f = fs.GetFile(FileToOpen)
    > > s = f.path
    > >
    > > Masterfile = ActiveWorkbook.Name
    > >
    > > STOPS AT THIS POINT : Workbooks.Open FileToOpen
    > >
    > > If Right(FileToOpen, 3) = "csv" Then
    > > Call ReadTouchUpCSV(s)
    > > ElseIf Right(FileToOpen, 3) = "txt" Then
    > > Call ReadTouchUpText
    > > End If
    > > End Sub
    > > =========================================

    >
    > --
    >
    > Dave Peterson
    >


  4. #4
    Dave Peterson
    Guest

    Re: VBA Stops Before competing the program

    Jan Karel Pieterse may have a work-around at:
    http://www.jkp-ads.com/Articles/WorkbookOpenBug.htm


    ch wrote:
    >
    > It worked. Thanks !
    >
    > "Dave Peterson" wrote:
    >
    > > When you open a file and hold down the shift key, excel thinks you want to avoid
    > > the Auto_open and workbook_open procedures.
    > >
    > > If your shortcut key includes the shift key, then excel stops -- it's kind of
    > > confused.
    > >
    > > So if you remove the shift key from the shortcut key combination, things should
    > > be back to normal.
    > >
    > > ch wrote:
    > > >
    > > > Hi Guys (that refers to all of you gurus out there) !!
    > > > I have a VBA that goes as below.
    > > >
    > > > The program STOPS (not break) executing at the "Workbooks.Open" line when I
    > > > assign it to short cut keys (eg Ctrl-Shift- T). There are several other
    > > > command lines yet to be executed.
    > > >
    > > > It works fine if I create a command button and assign MainTouchUp() macro to
    > > > the button.
    > > > It also works fine if I go to the Visual Basic Editor and hit "F5" in the
    > > > MainTouchUp() command lines.
    > > >
    > > > By the way, the MainTouchUp() and the ReadTouchUp() are in different user
    > > > modules, not sure if this affects the program.
    > > >
    > > > Please help.
    > > >
    > > > =========================================
    > > > Sub MainTouchUp()
    > > > ...
    > > > Call ReadTouchUp(FileToOpen)
    > > > ...
    > > > End Sub
    > > >
    > > > Sub ReadTouchUp(FileToOpen)
    > > > Dim fs, f, s
    > > >
    > > > Set fs = CreateObject("Scripting.FileSystemObject")
    > > > Set f = fs.GetFile(FileToOpen)
    > > > s = f.path
    > > >
    > > > Masterfile = ActiveWorkbook.Name
    > > >
    > > > STOPS AT THIS POINT : Workbooks.Open FileToOpen
    > > >
    > > > If Right(FileToOpen, 3) = "csv" Then
    > > > Call ReadTouchUpCSV(s)
    > > > ElseIf Right(FileToOpen, 3) = "txt" Then
    > > > Call ReadTouchUpText
    > > > End If
    > > > End Sub
    > > > =========================================

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson

+ 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