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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tell the dialog box "NO" 1

Status
Not open for further replies.

link9

Programmer
Nov 28, 2000
3,387
US
Hello all --

I have an application that I am trying to write that opens up one Excel file, copies a specified range, pastes it to another Excel file, and then closes both of them....

All this in a loop that may iterate a couple hundred times.

The problem is that when I try to close the stinking application, that sodding dialog box about "A large amount of data has been copied to your clipboard... Would you like for this information to be available..." blahblahblah is coming up and preventing me from closing the window. So that on the next iteration, it's trying to open another file (same name, different folder/file), and of course, it can't because a file with the same name is already open.

Anyway, the question is how to tell the dialog box that "IF I WANTED THE INFORMATION ON THE CLIPBOARD STILL, I WOULD NOT CLOSE THE APPLICATION!" or something to that effect. :)

Here is a bit of code:
Code:
fileName = File.Name
Set hoursWorld = appworld.Workbooks.Open(path & fileName)
        
Set hours = hoursWorld.Sheets("Sheet1")
hours.Range("A1").Select

hours.Range("A1", "D" & i).Copy

Set hours = Nothing
hoursWorld.Close

This code is in a loop, with the counter, 'i' (which is where the range selection gets its value), but that should make no difference.

Thanks for any input. :)
Paul Prewett
penny.gif
penny.gif
 
got it -- had to set the application's cutCopyMode = false
penny.gif
penny.gif
 
Other way of doing it, if you don't need the info on the clipboard was to do clipboard.clear on your code each time you were going close Excel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top