MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 28th, 2002, 02:22 PM   #1
elgringo56
Board Regular
 
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
Default

Here is a real dumb one, probably. Is there a way I can clear the clip board from within a macro?
elgringo56 is offline   Reply With Quote
Old Apr 28th, 2002, 02:53 PM   #2
brettvba
MrExcel MVP
 
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
Default

try

Sub ClearClipboard()
Application.CopyObjectsWithCells = False
Application.CutCopyMode = False
End Sub
brettvba is offline   Reply With Quote
Old May 27th, 2002, 10:19 AM   #3
vac
Board Regular
 
Join Date: May 2002
Posts: 211
Default

Further to my problem, the code previous does work to clear the clipboard, but only when there is oneitem in it. When there are two or more items in the clipboard it wont work no matter how many times you run it.
Im using exl 200 with the clipboard toolbar showing.
Please can anyone help???
vac is offline   Reply With Quote
Old May 27th, 2002, 04:54 PM   #4
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Quote:
On 2002-05-27 09:19, vac wrote:
Further to my problem, the code previous does work to clear the clipboard, but only when there is oneitem in it. When there are two or more items in the clipboard it wont work no matter how many times you run it.
Im using exl 200 with the clipboard toolbar showing.
Please can anyone help???

Sub ClearClipboardEl2000()
On Error Resume Next 'incase clipboard IS empty
Application.CommandBars("Clipboard").FindControl(ID:=3634).Execute
End Sub

__________________
Kind Regards,
Ivan F Moala From the City of Sails
Ivan F Moala is offline   Reply With Quote
Old Sep 7th, 2004, 04:00 PM   #5
Cbrine
Board Regular
 
Cbrine's Avatar
 
Join Date: Dec 2003
Location: Brampton
Posts: 3,185
Default Re: Clip board

Ivan,
I found this code for clearing the clipboard in XL2000, but it doesn't seem to work in Xl2002. I tried cycling through the controls on the Clipboard commandbar, but none were found?? I found that the clipboard manager is called "Task Pane", but it only has a single text box control. I tried cycling through commandbarbuttons, controls, and objects for Clipboard, and didn't find any? Can you let me know how you identified the ID?

Application.CommandBars("Clipboard").FindControl(ID:=3634).Execute

Thanks
__________________
Xcelerated Solutions
Office Automation Solutions for the Toronto Area
Cbrine is offline   Reply With Quote
Old Sep 7th, 2004, 04:22 PM   #6
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,388
Default Re: Clip board

I also get an error with that FindControl method using 2003.


elgringo56 - -

The clipbopard is a Windows object, not exclusively an Excel object. Excel supports a couple dozen data formats (BIFF4, BIFF5, etc) that might be present on the clipboard which must be addresed for the clipboard to truly be cleared.

Someone / anyone correct me if I am wrong or if your version of Excel fails with the following ClearClipboard macro, but it seems to work for me in all cases (drawing objects, charts, audio files...whatever is on the clipboard).


In a standard module:

Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long

Sub ClearClipboard()
OpenClipboard (0&)
EmptyClipboard
CloseClipboard
End Sub
__________________
Tom Urtis
Microsoft MVP - Excel
Tom Urtis is offline   Reply With Quote
Old Sep 7th, 2004, 05:51 PM   #7
Cbrine
Board Regular
 
Cbrine's Avatar
 
Join Date: Dec 2003
Location: Brampton
Posts: 3,185
Default Re: Clip board

Thanks Tom,
Maybe you can help me with an associated problem, why it is that I'm looking for this. I have a process that has 1 main worksheet with a filter. I then filter the data, based on another list, and copy the data to a new workbook. It will add worksheets to the new workbook until another variable changes, then it will save and close the new workbook, then start the cycle again.
The process slows down measureably by the 10 th worksheet, but then clears up when the workbook is saved and a new one is open. Watching from the task manager, you can see that memory usage going up in steps each time a worksheet is added. Then when the workbook is saved and closed, the memory drops like a ski slope. I believe that the macro running is preventing some type of clean up of memory from occuring or that the close is triggering a clean up at that point. The only problem is, is that when the excel clipboard manager is open, this doesn't seem to happen?? I don't understand why that would occur, but I thought the memory issue might be a build up in the clipboard, but that doesn't seem to be the case. It seems like when the excel clipboard manager is open, that excel deals with clipboard objects differently then when it's closed? I can run with the clipboard object open, but I want to determine how to release the used memory in code, if it's possible.
__________________
Xcelerated Solutions
Office Automation Solutions for the Toronto Area
Cbrine is offline   Reply With Quote
Old Sep 7th, 2004, 06:28 PM   #8
Zack Barresse
MrExcel MVP
 
Zack Barresse's Avatar
 
Join Date: Dec 2003
Location: Oregon, USA
Posts: 10,132
Default Re: Clip board

Quote:
Originally Posted by Tom Urtis
...Someone / anyone correct me if I am wrong or if your version of Excel fails with the following ClearClipboard macro, but it seems to work for me in all cases (drawing objects, charts, audio files...whatever is on the clipboard)...
Yup, works for me too. I use this quite often as I use my clipboard tremendously. I haven't found anything it doesn't work on yet.
__________________
Regards,
Zack Barresse

All Excel Functions
(If you would like comments in any code, please say so.)
Zack Barresse is offline   Reply With Quote
Old Sep 7th, 2004, 06:55 PM   #9
Tom Urtis
MrExcel MVP
 
Tom Urtis's Avatar
 
Join Date: Feb 2002
Location: San Francisco, California USA
Posts: 10,388
Default Re: Clip board

Cbrine - - If you post your code it would be easier to identify areas where your memory is being used. My guess (only a guess because I have not sen your code) is that maybe you are setting variables for ranges or worksheets but not setting them back to Nothing, or there is excessive selecting or activating, or you are declaring variables as Variant when other less-burdensome variable types would suffice, or you are temporarily copying & saving more data on the clipboard (formulas or formatting) than necessary, or who knows what else. Post your macro and someone may be able to point out areas where an improvement is possible. It would also help if you give whatever detailed text description you can along with the code, so people can see why you are doing what you are doing and maybe suggest alternative approaches.
__________________
Tom Urtis
Microsoft MVP - Excel
Tom Urtis is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On

Forum Jump


All times are GMT -4. The time now is 03:54 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes