ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert a key function in VBA script (https://www.excelbanter.com/excel-programming/330246-insert-key-function-vba-script.html)

Bowes813

Insert a key function in VBA script
 

I need a function that is going to hit the "Y" key for me. When I run a
certain macro, it wants to send a file to a certain location to update
it and replace the old one. During this I have to hit the "Y" key to
say yes. I want to add something to the script so I dont have to do
this and then finally the script will be able to run on its own without
me.

Trevor


--
Bowes813
------------------------------------------------------------------------
Bowes813's Profile: http://www.excelforum.com/member.php...o&userid=23779
View this thread: http://www.excelforum.com/showthread...hreadid=374160


dominicb[_7_]

Insert a key function in VBA script
 

Good evening Bowes13

Use this command at the start of your code:

Application.DisplayAlerts = False

and this at the end of your code:

Application.DisplayAlerts = True

This will force the macro to not ask you a question, but choose th
default option on your behalf (which would be OK - overwrite th
file).

HTH

Dominic

--
dominic
-----------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...fo&userid=1893
View this thread: http://www.excelforum.com/showthread.php?threadid=37416


Bowes813[_2_]

Insert a key function in VBA script
 

What if my default is No

--
Bowes81
-----------------------------------------------------------------------
Bowes813's Profile: http://www.excelforum.com/member.php...fo&userid=2377
View this thread: http://www.excelforum.com/showthread.php?threadid=37416


dominicb[_8_]

Insert a key function in VBA script
 

Hi Bowes813

What I said in my answer was correct, but I think perhaps I could have
explained it a little better. this command will set your default value
for the question to true and answer the question for you. Indeed, this
is what the Excel 2003 help file has to say about the DisplayAlerts
property:

"When using the SaveAs method for workbooks to overwrite an existing
file, the 'Overwrite' alert has a default of 'No', while the 'Yes'
response is selected by Excel when the DisplayAlerts property is set
equal to True."

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=374160



All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com