PC Review


Reply
Thread Tools Rate Thread

Bypass Auto_Open

 
 
Brian
Guest
Posts: n/a
 
      4th Oct 2008
I think that I should be able to bypass an Auto_Open macro by holding down
Shift while opening the workbook. However, I have this Auto_Open macro:

Sub Auto_Open()
Workbooks.Open FileName:="C:\MyFile.xls"
Rows("1:14").Select
Selection.Delete Shift:=xlUp
Selection.End(xlDown).Select
ActiveCell.EntireRow.Delete
Selection.End(xlUp).Select
ActiveCell.EntireRow.Delete
Range("A1").Select
ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
CreateBackup:=False
ActiveWindow.Close
'close Excel
Application.Quit
End Sub

Even when I hold down Shift, the macro runs the first line:

Workbooks.Open FileName:="C:\MyFile.xls"

How can I keep it from running even this much when I open the workbook
having the macro in it?
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      4th Oct 2008
When I use file|open to select the file to open, then hit and hold the shift key
while clicking on the Open button, then clicking the "yes" button (to allow
macros--my security setting) while continuing to hold down the shift button, the
auto_open procedure doesn't run.

What steps are you using where the code runs?

Brian wrote:
>
> I think that I should be able to bypass an Auto_Open macro by holding down
> Shift while opening the workbook. However, I have this Auto_Open macro:
>
> Sub Auto_Open()
> Workbooks.Open FileName:="C:\MyFile.xls"
> Rows("1:14").Select
> Selection.Delete Shift:=xlUp
> Selection.End(xlDown).Select
> ActiveCell.EntireRow.Delete
> Selection.End(xlUp).Select
> ActiveCell.EntireRow.Delete
> Range("A1").Select
> ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
> Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
> CreateBackup:=False
> ActiveWindow.Close
> 'close Excel
> Application.Quit
> End Sub
>
> Even when I hold down Shift, the macro runs the first line:
>
> Workbooks.Open FileName:="C:\MyFile.xls"
>
> How can I keep it from running even this much when I open the workbook
> having the macro in it?


--

Dave Peterson
 
Reply With Quote
 
Brian
Guest
Posts: n/a
 
      4th Oct 2008
It works the way you described when clicking File -> Open. However, I
normally highlight the file name in Windows Explorer, hold down Shift, then
Press the Enter key. I have macro security set to Low to enable simple
Access integration, so there is no intervening security message.

Curiously, it does not run the entire macro when I do this - only the first
line where it opens the other file. It does not proceed to the row selection
code, etc.

Also, curiously, when I add a MsgBox (or more than one) before the first
line in the macro, it runs the MsgBox AND the first line:

Sub Auto_Open()
MsgBox "This is a test."
MsgBox "This is a test2."
Workbooks.Open FileName:="C:\MyFile.xls"
THE MACRO STOPS HERE AND DOES NOT PROCEED
Rows("1:14").Select
Selection.Delete Shift:=xlUp
Selection.End(xlDown).Select

"Dave Peterson" wrote:

> When I use file|open to select the file to open, then hit and hold the shift key
> while clicking on the Open button, then clicking the "yes" button (to allow
> macros--my security setting) while continuing to hold down the shift button, the
> auto_open procedure doesn't run.
>
> What steps are you using where the code runs?
>
> Brian wrote:
> >
> > I think that I should be able to bypass an Auto_Open macro by holding down
> > Shift while opening the workbook. However, I have this Auto_Open macro:
> >
> > Sub Auto_Open()
> > Workbooks.Open FileName:="C:\MyFile.xls"
> > Rows("1:14").Select
> > Selection.Delete Shift:=xlUp
> > Selection.End(xlDown).Select
> > ActiveCell.EntireRow.Delete
> > Selection.End(xlUp).Select
> > ActiveCell.EntireRow.Delete
> > Range("A1").Select
> > ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
> > Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
> > CreateBackup:=False
> > ActiveWindow.Close
> > 'close Excel
> > Application.Quit
> > End Sub
> >
> > Even when I hold down Shift, the macro runs the first line:
> >
> > Workbooks.Open FileName:="C:\MyFile.xls"
> >
> > How can I keep it from running even this much when I open the workbook
> > having the macro in it?

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      4th Oct 2008
I have a workbook that I sometimes want to execute the code on and sometimes
not when I open it. I've put something like this in the beginning of the
auto-open

Dim Verify as MSOMsgBoxResult '<~~~I think that's it

Verify = MsgBox("Do you want to do XYZ?",vbyesno)

If Verify = VBNo then exit sub


--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"Brian" wrote:

> It works the way you described when clicking File -> Open. However, I
> normally highlight the file name in Windows Explorer, hold down Shift, then
> Press the Enter key. I have macro security set to Low to enable simple
> Access integration, so there is no intervening security message.
>
> Curiously, it does not run the entire macro when I do this - only the first
> line where it opens the other file. It does not proceed to the row selection
> code, etc.
>
> Also, curiously, when I add a MsgBox (or more than one) before the first
> line in the macro, it runs the MsgBox AND the first line:
>
> Sub Auto_Open()
> MsgBox "This is a test."
> MsgBox "This is a test2."
> Workbooks.Open FileName:="C:\MyFile.xls"
> THE MACRO STOPS HERE AND DOES NOT PROCEED
> Rows("1:14").Select
> Selection.Delete Shift:=xlUp
> Selection.End(xlDown).Select
>
> "Dave Peterson" wrote:
>
> > When I use file|open to select the file to open, then hit and hold the shift key
> > while clicking on the Open button, then clicking the "yes" button (to allow
> > macros--my security setting) while continuing to hold down the shift button, the
> > auto_open procedure doesn't run.
> >
> > What steps are you using where the code runs?
> >
> > Brian wrote:
> > >
> > > I think that I should be able to bypass an Auto_Open macro by holding down
> > > Shift while opening the workbook. However, I have this Auto_Open macro:
> > >
> > > Sub Auto_Open()
> > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > Rows("1:14").Select
> > > Selection.Delete Shift:=xlUp
> > > Selection.End(xlDown).Select
> > > ActiveCell.EntireRow.Delete
> > > Selection.End(xlUp).Select
> > > ActiveCell.EntireRow.Delete
> > > Range("A1").Select
> > > ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
> > > Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
> > > CreateBackup:=False
> > > ActiveWindow.Close
> > > 'close Excel
> > > Application.Quit
> > > End Sub
> > >
> > > Even when I hold down Shift, the macro runs the first line:
> > >
> > > Workbooks.Open FileName:="C:\MyFile.xls"
> > >
> > > How can I keep it from running even this much when I open the workbook
> > > having the macro in it?

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

 
Reply With Quote
 
Jac Tremblay
Guest
Posts: n/a
 
      4th Oct 2008
Hi Barb,
I get an error on MSOMsgBoxResult when I try to compile the project:
User-defined type not defined.
Which reference should I add to my project?
I use Excel 2007.

Thanks.
--
Jac Tremblay


"Barb Reinhardt" wrote:

> I have a workbook that I sometimes want to execute the code on and sometimes
> not when I open it. I've put something like this in the beginning of the
> auto-open
>
> Dim Verify as MSOMsgBoxResult '<~~~I think that's it
>
> Verify = MsgBox("Do you want to do XYZ?",vbyesno)
>
> If Verify = VBNo then exit sub
>
>
> --
> HTH,
> Barb Reinhardt
>
> If this post was helpful to you, please click YES below.
>
>
>
> "Brian" wrote:
>
> > It works the way you described when clicking File -> Open. However, I
> > normally highlight the file name in Windows Explorer, hold down Shift, then
> > Press the Enter key. I have macro security set to Low to enable simple
> > Access integration, so there is no intervening security message.
> >
> > Curiously, it does not run the entire macro when I do this - only the first
> > line where it opens the other file. It does not proceed to the row selection
> > code, etc.
> >
> > Also, curiously, when I add a MsgBox (or more than one) before the first
> > line in the macro, it runs the MsgBox AND the first line:
> >
> > Sub Auto_Open()
> > MsgBox "This is a test."
> > MsgBox "This is a test2."
> > Workbooks.Open FileName:="C:\MyFile.xls"
> > THE MACRO STOPS HERE AND DOES NOT PROCEED
> > Rows("1:14").Select
> > Selection.Delete Shift:=xlUp
> > Selection.End(xlDown).Select
> >
> > "Dave Peterson" wrote:
> >
> > > When I use file|open to select the file to open, then hit and hold the shift key
> > > while clicking on the Open button, then clicking the "yes" button (to allow
> > > macros--my security setting) while continuing to hold down the shift button, the
> > > auto_open procedure doesn't run.
> > >
> > > What steps are you using where the code runs?
> > >
> > > Brian wrote:
> > > >
> > > > I think that I should be able to bypass an Auto_Open macro by holding down
> > > > Shift while opening the workbook. However, I have this Auto_Open macro:
> > > >
> > > > Sub Auto_Open()
> > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > Rows("1:14").Select
> > > > Selection.Delete Shift:=xlUp
> > > > Selection.End(xlDown).Select
> > > > ActiveCell.EntireRow.Delete
> > > > Selection.End(xlUp).Select
> > > > ActiveCell.EntireRow.Delete
> > > > Range("A1").Select
> > > > ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
> > > > Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
> > > > CreateBackup:=False
> > > > ActiveWindow.Close
> > > > 'close Excel
> > > > Application.Quit
> > > > End Sub
> > > >
> > > > Even when I hold down Shift, the macro runs the first line:
> > > >
> > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > >
> > > > How can I keep it from running even this much when I open the workbook
> > > > having the macro in it?
> > >
> > > --
> > >
> > > Dave Peterson
> > >

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th Oct 2008
Dim Verify as Long

Jac Tremblay wrote:
>
> Hi Barb,
> I get an error on MSOMsgBoxResult when I try to compile the project:
> User-defined type not defined.
> Which reference should I add to my project?
> I use Excel 2007.
>
> Thanks.
> --
> Jac Tremblay
>
> "Barb Reinhardt" wrote:
>
> > I have a workbook that I sometimes want to execute the code on and sometimes
> > not when I open it. I've put something like this in the beginning of the
> > auto-open
> >
> > Dim Verify as MSOMsgBoxResult '<~~~I think that's it
> >
> > Verify = MsgBox("Do you want to do XYZ?",vbyesno)
> >
> > If Verify = VBNo then exit sub
> >
> >
> > --
> > HTH,
> > Barb Reinhardt
> >
> > If this post was helpful to you, please click YES below.
> >
> >
> >
> > "Brian" wrote:
> >
> > > It works the way you described when clicking File -> Open. However, I
> > > normally highlight the file name in Windows Explorer, hold down Shift, then
> > > Press the Enter key. I have macro security set to Low to enable simple
> > > Access integration, so there is no intervening security message.
> > >
> > > Curiously, it does not run the entire macro when I do this - only the first
> > > line where it opens the other file. It does not proceed to the row selection
> > > code, etc.
> > >
> > > Also, curiously, when I add a MsgBox (or more than one) before the first
> > > line in the macro, it runs the MsgBox AND the first line:
> > >
> > > Sub Auto_Open()
> > > MsgBox "This is a test."
> > > MsgBox "This is a test2."
> > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > THE MACRO STOPS HERE AND DOES NOT PROCEED
> > > Rows("1:14").Select
> > > Selection.Delete Shift:=xlUp
> > > Selection.End(xlDown).Select
> > >
> > > "Dave Peterson" wrote:
> > >
> > > > When I use file|open to select the file to open, then hit and hold the shift key
> > > > while clicking on the Open button, then clicking the "yes" button (to allow
> > > > macros--my security setting) while continuing to hold down the shift button, the
> > > > auto_open procedure doesn't run.
> > > >
> > > > What steps are you using where the code runs?
> > > >
> > > > Brian wrote:
> > > > >
> > > > > I think that I should be able to bypass an Auto_Open macro by holding down
> > > > > Shift while opening the workbook. However, I have this Auto_Open macro:
> > > > >
> > > > > Sub Auto_Open()
> > > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > > Rows("1:14").Select
> > > > > Selection.Delete Shift:=xlUp
> > > > > Selection.End(xlDown).Select
> > > > > ActiveCell.EntireRow.Delete
> > > > > Selection.End(xlUp).Select
> > > > > ActiveCell.EntireRow.Delete
> > > > > Range("A1").Select
> > > > > ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
> > > > > Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
> > > > > CreateBackup:=False
> > > > > ActiveWindow.Close
> > > > > 'close Excel
> > > > > Application.Quit
> > > > > End Sub
> > > > >
> > > > > Even when I hold down Shift, the macro runs the first line:
> > > > >
> > > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > >
> > > > > How can I keep it from running even this much when I open the workbook
> > > > > having the macro in it?
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > >


--

Dave Peterson
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th Oct 2008
I tried your method (xl2003 on win xp home).

I held the shift key until the file was open--I didn't release it.

If excel was closed, I got a few messages that my addins wouldn't open. But my
workbook opened fine and the auto_open procedure didn't run.

If excel was open, my workbook opened fine and the auto_Open procedure didn't
run.

I'm guessing that you release the shift key too soon.

Brian wrote:
>
> It works the way you described when clicking File -> Open. However, I
> normally highlight the file name in Windows Explorer, hold down Shift, then
> Press the Enter key. I have macro security set to Low to enable simple
> Access integration, so there is no intervening security message.
>
> Curiously, it does not run the entire macro when I do this - only the first
> line where it opens the other file. It does not proceed to the row selection
> code, etc.
>
> Also, curiously, when I add a MsgBox (or more than one) before the first
> line in the macro, it runs the MsgBox AND the first line:
>
> Sub Auto_Open()
> MsgBox "This is a test."
> MsgBox "This is a test2."
> Workbooks.Open FileName:="C:\MyFile.xls"
> THE MACRO STOPS HERE AND DOES NOT PROCEED
> Rows("1:14").Select
> Selection.Delete Shift:=xlUp
> Selection.End(xlDown).Select
>
> "Dave Peterson" wrote:
>
> > When I use file|open to select the file to open, then hit and hold the shift key
> > while clicking on the Open button, then clicking the "yes" button (to allow
> > macros--my security setting) while continuing to hold down the shift button, the
> > auto_open procedure doesn't run.
> >
> > What steps are you using where the code runs?
> >
> > Brian wrote:
> > >
> > > I think that I should be able to bypass an Auto_Open macro by holding down
> > > Shift while opening the workbook. However, I have this Auto_Open macro:
> > >
> > > Sub Auto_Open()
> > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > Rows("1:14").Select
> > > Selection.Delete Shift:=xlUp
> > > Selection.End(xlDown).Select
> > > ActiveCell.EntireRow.Delete
> > > Selection.End(xlUp).Select
> > > ActiveCell.EntireRow.Delete
> > > Range("A1").Select
> > > ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
> > > Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
> > > CreateBackup:=False
> > > ActiveWindow.Close
> > > 'close Excel
> > > Application.Quit
> > > End Sub
> > >
> > > Even when I hold down Shift, the macro runs the first line:
> > >
> > > Workbooks.Open FileName:="C:\MyFile.xls"
> > >
> > > How can I keep it from running even this much when I open the workbook
> > > having the macro in it?

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


--

Dave Peterson
 
Reply With Quote
 
Barb Reinhardt
Guest
Posts: n/a
 
      4th Oct 2008
Oops, I was wrong. I use this

Dim Verify As VbMsgBoxResult

Sorry about that.

Barb Reinhardt

"Jac Tremblay" wrote:

> Hi Barb,
> I get an error on MSOMsgBoxResult when I try to compile the project:
> User-defined type not defined.
> Which reference should I add to my project?
> I use Excel 2007.
>
> Thanks.
> --
> Jac Tremblay
>
>
> "Barb Reinhardt" wrote:
>
> > I have a workbook that I sometimes want to execute the code on and sometimes
> > not when I open it. I've put something like this in the beginning of the
> > auto-open
> >
> > Dim Verify as MSOMsgBoxResult '<~~~I think that's it
> >
> > Verify = MsgBox("Do you want to do XYZ?",vbyesno)
> >
> > If Verify = VBNo then exit sub
> >
> >
> > --
> > HTH,
> > Barb Reinhardt
> >
> > If this post was helpful to you, please click YES below.
> >
> >
> >
> > "Brian" wrote:
> >
> > > It works the way you described when clicking File -> Open. However, I
> > > normally highlight the file name in Windows Explorer, hold down Shift, then
> > > Press the Enter key. I have macro security set to Low to enable simple
> > > Access integration, so there is no intervening security message.
> > >
> > > Curiously, it does not run the entire macro when I do this - only the first
> > > line where it opens the other file. It does not proceed to the row selection
> > > code, etc.
> > >
> > > Also, curiously, when I add a MsgBox (or more than one) before the first
> > > line in the macro, it runs the MsgBox AND the first line:
> > >
> > > Sub Auto_Open()
> > > MsgBox "This is a test."
> > > MsgBox "This is a test2."
> > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > THE MACRO STOPS HERE AND DOES NOT PROCEED
> > > Rows("1:14").Select
> > > Selection.Delete Shift:=xlUp
> > > Selection.End(xlDown).Select
> > >
> > > "Dave Peterson" wrote:
> > >
> > > > When I use file|open to select the file to open, then hit and hold the shift key
> > > > while clicking on the Open button, then clicking the "yes" button (to allow
> > > > macros--my security setting) while continuing to hold down the shift button, the
> > > > auto_open procedure doesn't run.
> > > >
> > > > What steps are you using where the code runs?
> > > >
> > > > Brian wrote:
> > > > >
> > > > > I think that I should be able to bypass an Auto_Open macro by holding down
> > > > > Shift while opening the workbook. However, I have this Auto_Open macro:
> > > > >
> > > > > Sub Auto_Open()
> > > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > > Rows("1:14").Select
> > > > > Selection.Delete Shift:=xlUp
> > > > > Selection.End(xlDown).Select
> > > > > ActiveCell.EntireRow.Delete
> > > > > Selection.End(xlUp).Select
> > > > > ActiveCell.EntireRow.Delete
> > > > > Range("A1").Select
> > > > > ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
> > > > > Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
> > > > > CreateBackup:=False
> > > > > ActiveWindow.Close
> > > > > 'close Excel
> > > > > Application.Quit
> > > > > End Sub
> > > > >
> > > > > Even when I hold down Shift, the macro runs the first line:
> > > > >
> > > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > >
> > > > > How can I keep it from running even this much when I open the workbook
> > > > > having the macro in it?
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > >

 
Reply With Quote
 
Jac Tremblay
Guest
Posts: n/a
 
      4th Oct 2008
Thanks Barb, you make my day.
It works fine and it is a good idea that I am sure many users will benefit
from.
I love you.
--
Jac Tremblay


"Barb Reinhardt" wrote:

> Oops, I was wrong. I use this
>
> Dim Verify As VbMsgBoxResult
>
> Sorry about that.
>
> Barb Reinhardt
>
> "Jac Tremblay" wrote:
>
> > Hi Barb,
> > I get an error on MSOMsgBoxResult when I try to compile the project:
> > User-defined type not defined.
> > Which reference should I add to my project?
> > I use Excel 2007.
> >
> > Thanks.
> > --
> > Jac Tremblay
> >
> >
> > "Barb Reinhardt" wrote:
> >
> > > I have a workbook that I sometimes want to execute the code on and sometimes
> > > not when I open it. I've put something like this in the beginning of the
> > > auto-open
> > >
> > > Dim Verify as MSOMsgBoxResult '<~~~I think that's it
> > >
> > > Verify = MsgBox("Do you want to do XYZ?",vbyesno)
> > >
> > > If Verify = VBNo then exit sub
> > >
> > >
> > > --
> > > HTH,
> > > Barb Reinhardt
> > >
> > > If this post was helpful to you, please click YES below.
> > >
> > >
> > >
> > > "Brian" wrote:
> > >
> > > > It works the way you described when clicking File -> Open. However, I
> > > > normally highlight the file name in Windows Explorer, hold down Shift, then
> > > > Press the Enter key. I have macro security set to Low to enable simple
> > > > Access integration, so there is no intervening security message.
> > > >
> > > > Curiously, it does not run the entire macro when I do this - only the first
> > > > line where it opens the other file. It does not proceed to the row selection
> > > > code, etc.
> > > >
> > > > Also, curiously, when I add a MsgBox (or more than one) before the first
> > > > line in the macro, it runs the MsgBox AND the first line:
> > > >
> > > > Sub Auto_Open()
> > > > MsgBox "This is a test."
> > > > MsgBox "This is a test2."
> > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > THE MACRO STOPS HERE AND DOES NOT PROCEED
> > > > Rows("1:14").Select
> > > > Selection.Delete Shift:=xlUp
> > > > Selection.End(xlDown).Select
> > > >
> > > > "Dave Peterson" wrote:
> > > >
> > > > > When I use file|open to select the file to open, then hit and hold the shift key
> > > > > while clicking on the Open button, then clicking the "yes" button (to allow
> > > > > macros--my security setting) while continuing to hold down the shift button, the
> > > > > auto_open procedure doesn't run.
> > > > >
> > > > > What steps are you using where the code runs?
> > > > >
> > > > > Brian wrote:
> > > > > >
> > > > > > I think that I should be able to bypass an Auto_Open macro by holding down
> > > > > > Shift while opening the workbook. However, I have this Auto_Open macro:
> > > > > >
> > > > > > Sub Auto_Open()
> > > > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > > > Rows("1:14").Select
> > > > > > Selection.Delete Shift:=xlUp
> > > > > > Selection.End(xlDown).Select
> > > > > > ActiveCell.EntireRow.Delete
> > > > > > Selection.End(xlUp).Select
> > > > > > ActiveCell.EntireRow.Delete
> > > > > > Range("A1").Select
> > > > > > ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
> > > > > > Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
> > > > > > CreateBackup:=False
> > > > > > ActiveWindow.Close
> > > > > > 'close Excel
> > > > > > Application.Quit
> > > > > > End Sub
> > > > > >
> > > > > > Even when I hold down Shift, the macro runs the first line:
> > > > > >
> > > > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > > >
> > > > > > How can I keep it from running even this much when I open the workbook
> > > > > > having the macro in it?
> > > > >
> > > > > --
> > > > >
> > > > > Dave Peterson
> > > > >

 
Reply With Quote
 
Jac Tremblay
Guest
Posts: n/a
 
      4th Oct 2008
Hi Dave,
It works fine with your solution as well.
Thanks a lot.
--
Jac Tremblay


"Dave Peterson" wrote:

> Dim Verify as Long
>
> Jac Tremblay wrote:
> >
> > Hi Barb,
> > I get an error on MSOMsgBoxResult when I try to compile the project:
> > User-defined type not defined.
> > Which reference should I add to my project?
> > I use Excel 2007.
> >
> > Thanks.
> > --
> > Jac Tremblay
> >
> > "Barb Reinhardt" wrote:
> >
> > > I have a workbook that I sometimes want to execute the code on and sometimes
> > > not when I open it. I've put something like this in the beginning of the
> > > auto-open
> > >
> > > Dim Verify as MSOMsgBoxResult '<~~~I think that's it
> > >
> > > Verify = MsgBox("Do you want to do XYZ?",vbyesno)
> > >
> > > If Verify = VBNo then exit sub
> > >
> > >
> > > --
> > > HTH,
> > > Barb Reinhardt
> > >
> > > If this post was helpful to you, please click YES below.
> > >
> > >
> > >
> > > "Brian" wrote:
> > >
> > > > It works the way you described when clicking File -> Open. However, I
> > > > normally highlight the file name in Windows Explorer, hold down Shift, then
> > > > Press the Enter key. I have macro security set to Low to enable simple
> > > > Access integration, so there is no intervening security message.
> > > >
> > > > Curiously, it does not run the entire macro when I do this - only the first
> > > > line where it opens the other file. It does not proceed to the row selection
> > > > code, etc.
> > > >
> > > > Also, curiously, when I add a MsgBox (or more than one) before the first
> > > > line in the macro, it runs the MsgBox AND the first line:
> > > >
> > > > Sub Auto_Open()
> > > > MsgBox "This is a test."
> > > > MsgBox "This is a test2."
> > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > THE MACRO STOPS HERE AND DOES NOT PROCEED
> > > > Rows("1:14").Select
> > > > Selection.Delete Shift:=xlUp
> > > > Selection.End(xlDown).Select
> > > >
> > > > "Dave Peterson" wrote:
> > > >
> > > > > When I use file|open to select the file to open, then hit and hold the shift key
> > > > > while clicking on the Open button, then clicking the "yes" button (to allow
> > > > > macros--my security setting) while continuing to hold down the shift button, the
> > > > > auto_open procedure doesn't run.
> > > > >
> > > > > What steps are you using where the code runs?
> > > > >
> > > > > Brian wrote:
> > > > > >
> > > > > > I think that I should be able to bypass an Auto_Open macro by holding down
> > > > > > Shift while opening the workbook. However, I have this Auto_Open macro:
> > > > > >
> > > > > > Sub Auto_Open()
> > > > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > > > Rows("1:14").Select
> > > > > > Selection.Delete Shift:=xlUp
> > > > > > Selection.End(xlDown).Select
> > > > > > ActiveCell.EntireRow.Delete
> > > > > > Selection.End(xlUp).Select
> > > > > > ActiveCell.EntireRow.Delete
> > > > > > Range("A1").Select
> > > > > > ActiveWorkbook.SaveAs FileName:="C:\MyFile2.xls", FileFormat:=xlNormal,
> > > > > > Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
> > > > > > CreateBackup:=False
> > > > > > ActiveWindow.Close
> > > > > > 'close Excel
> > > > > > Application.Quit
> > > > > > End Sub
> > > > > >
> > > > > > Even when I hold down Shift, the macro runs the first line:
> > > > > >
> > > > > > Workbooks.Open FileName:="C:\MyFile.xls"
> > > > > >
> > > > > > How can I keep it from running even this much when I open the workbook
> > > > > > having the macro in it?
> > > > >
> > > > > --
> > > > >
> > > > > Dave Peterson
> > > > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bypass Auto_open Macro in Excel 2007 BradJohnson Microsoft Excel Misc 3 9th Apr 2009 05:28 PM
Bypass SHIFt bypass mrgrine@gmail.com Microsoft Access Form Coding 3 10th Mar 2008 08:25 PM
Holding Shift to bypass Auto_Open doesn't work in Excel 2007... WATYF1@gmail.com Microsoft Excel Programming 4 18th Dec 2006 03:40 PM
Auto_Open() HELP misko Microsoft Powerpoint 0 15th Feb 2006 01:51 PM
auto_open? Jack Sons Microsoft Excel Misc 0 22nd Feb 2005 09:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:41 PM.