Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendKeys

Status
Not open for further replies.

samato

Technical User
Apr 26, 2003
37
US
I am using the OutputTo in a macro and the file already exists so after the OutputTo I am trying to send "Y" to tell it to overwrite the old file and it doesn't work. Any ideas?
 
Doesn't setwarnings to False solve this problem?

ChaZ

Ascii dumb question, get a dumb Ansi
 
I wish SetWarnings worked that way. It appears that SetWarnings is only for "...about to delete a table" It has no affect when you are about to "OutputTo" a file. I have this in the beginning of each Macro though. I read something at Microsoft KB but can't find it again.
 
You are using a macro to export? Have you considered VBA instead? I don't have the problem you describe, and I use VBA to do this.

In the VBA code, use Docmd.Transfer... The Help screen will basicly walk you through it.

With Send Keys though, use {Tab}{Enter}. Probably you already did this, but you said it doesn't work. I dunno why.

Chaz

Ascii dumb question, get a dumb Ansi
 
I appreciate you helping me with this. I don't know much VBA.
 
SendKeys is VERY dangerous. It will send to the active window so if you click somewhere else, that window will perform the keystrokes sent. It allows the possibility of all sorts of nasty stuff happening (e.g Send delete key when in Windows Explorer).

You really need to look at Transfer(Text|Spreadsheet) in Macros.

Craig
 
Dear samato,

A simple solution would be to test to see if the file you are about to create already exists.

If it exists, then delete it first.

This way, you will never see the overwrite confirmation, because there will not be a file.

You can do this very easily in VBA.

Good Luck,
Hap [2thumbsup]

Access Developer [pc] Access based Add-on Solutions
Access Consultants forum
 
Hap,

Good idea! But there's no need to test.

Code:
On Error Resume Next

Kill "FileName"
DoCmd.OutputTo etc.

Craig
 
Craig, Hap, - Sorry but I don't know much VBA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top