How to use this DeleteEMFs() Macro

This macro was on the MicroSoft website as a work around for the .emf
storage problem

http://support.microsoft.com/default.aspx?scid=kb;en-us;299372

What exactly does this macro do and how should I use it?  I want to
remove all the .emf files from a particular Excel File.  B/c the
workbook creates hundreds or thousands of temp .emf files everytime it
opens and it takes forever to open..

Thank you very much for any help!

george

Private Sub Workbook_Open()
   Call DeleteEMFs
End Sub


Private Sub DeleteEMFs()
 Dim fso As Variant
 Set fso = CreateObject("Scripting.FileSystemObject")
 Dim fs As FileSearch
 Dim i As Long
 Set fs = Application.FileSearch
 With fs
    .LookIn = fso.GetSpecialFolder(2)
    .Filename = "*.emf"

      If .Execute(SortBy:=msoSortByFileName,
SortOrder:=msoSortOrderAscending) > 0 Then
       On Error Resume Next
       For i = 1 To .FoundFiles.Count
       Kill .FoundFiles(i)
       Next i
       On Error GoTo 0
      End If

 End With

 Set fso = Nothing
 Set fs = Nothing
End Sub

0
giorgio1 (6)
7/28/2005 6:14:15 PM
excel 39879 articles. 2 followers. Follow

1 Replies
650 Views

Similar Articles

[PageSpeed] 23

It almost does the same thing as that script (in the previous thread).

This version has:
..LookIn = fso.GetSpecialFolder(2)
(2 represents the Windows Temp folder)

But this version only looks for *.emf files and deletes them.

I didn't try this, but I don't think you would want to run this from the
workbook that causes the trouble.  The workbook is already open by the time the
workbook_open event fires.

But you could change it slightly so that it cleans the temp folder, opens your
file, and closes this "cleaner" workbook:

Private Sub Workbook_Open()
   Call DeleteEMFs
   workbooks.open filename:="C:\yourpath\yourfile.xls"
   me.close
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

But for me, I'll continue to clean up using that .VBS script.  I don't have to
start excel to run it and it cleans up more stuff (yeah, you could modify that
macro, though).



giorgio@gmail.com wrote:
> 
> This macro was on the MicroSoft website as a work around for the .emf
> storage problem
> 
> http://support.microsoft.com/default.aspx?scid=kb;en-us;299372
> 
> What exactly does this macro do and how should I use it?  I want to
> remove all the .emf files from a particular Excel File.  B/c the
> workbook creates hundreds or thousands of temp .emf files everytime it
> opens and it takes forever to open..
> 
> Thank you very much for any help!
> 
> george
> 
> Private Sub Workbook_Open()
>    Call DeleteEMFs
> End Sub
> 
> Private Sub DeleteEMFs()
>  Dim fso As Variant
>  Set fso = CreateObject("Scripting.FileSystemObject")
>  Dim fs As FileSearch
>  Dim i As Long
>  Set fs = Application.FileSearch
>  With fs
>     .LookIn = fso.GetSpecialFolder(2)
>     .Filename = "*.emf"
> 
>       If .Execute(SortBy:=msoSortByFileName,
> SortOrder:=msoSortOrderAscending) > 0 Then
>        On Error Resume Next
>        For i = 1 To .FoundFiles.Count
>        Kill .FoundFiles(i)
>        Next i
>        On Error GoTo 0
>       End If
> 
>  End With
> 
>  Set fso = Nothing
>  Set fs = Nothing
> End Sub

-- 

Dave Peterson
0
petersod (12005)
7/28/2005 10:33:25 PM
Reply:

Similar Artilces:

Macros to Button
Can someone please tell me how to assign Macros to a Button? http://www.ozgrid.com/Excel/assign-macros.htm -- Regards Dave Hawley www.ozgrid.com "Premal" <Premal@discussions.microsoft.com> wrote in message news:026F76B8-CEC2-47B5-9581-66849F0627D8@microsoft.com... > Can someone please tell me how to assign Macros to a Button? Use buttons from the Forms toolbar (View|Toolbars in xl2003 menus) to see that toolbar. Then click on the button and plop it on a sheet somewhere. You'll be prompted to assign the macro right there. If you don't want...

software to allow 2007 documents to be read using 2003
I have installed the Microsoft software so that I can read MS word 2007 in MS office 2003. As soon as I loaded it, a warning came up to say my copy of Office 2003 was counterfeit. I loaded 2003 from a master disk and have the licence sticker and have been using it for 18 months without any problems, and receiving updates etc. It was registered correctly with Microsoft. Help please. ...

problem using excel function in vba
Hi I have just been working on vba for the last 2 days only so please pardon my lack of understanding of even the very basic terms Basically, I have made an excel sheet where I have automated a process of copying a specific range of rows from sheet 1 to different sheets using for loop. everytime the loop finishes, it moves onto the next column to copy the values again. This goes on when I press the start timer button Ideally what I want to do is when I press the stop timer button, my code should automatically move onto the next column and do a calculation (variance) of al...

XmlBookmarkReader bug using ReadSubtree
I have discovered a bug in XmlBookmarkReader (code provided by MSDN, but not necessarily supported by Microsoft). The article is found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/XmlBkMkRead.asp Consider the following code to print xml. This code assumes that the xml text given in the reader will be of a certain form -- basically having a root node, which is not a crazy assumption at all. It just makes the code simpler to demonstrate the bug. public static void PrintXml(XmlReader reader) { bool inElement = false; string elementName="&qu...

deleting rows using X search and last row
I have a column H that has numbers in it. I want to find down the column for an X. When the X is found I need to select that row that X is in and select the last row with data and delete the selected rows. Hi try the following macro: Sub delete_rows() Dim lastrow As Long Dim row_index As Long Application.ScreenUpdating = False lastrow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row For row_index = 1 to lastrow If Cells(row_index, "A").Value= " X" then Rows(row_index & ":" & lastrow).delete exit for End If Ne...

Define a chart using VBA
Hi folks, I'm baffled- I'm writing a macro to pull a data table into an excel sheet & create a bargraph of those results. The number of records in the data table are variable (say between 2 and 50). I'm trying to define a dynamic bar graph using VBA. The X values are in col C and the text Y vlaues are in col A. (both start in row 3) The values in column B are necessary, but have nothing to do with the graph. I'm having trouble using variables to define the source data as two, non adjacent ranges. I've had problems just including the 50 cells in the data table ...

Macros and protected cells
I wrote a macro to hide cells containing certain data after thei references were added. It was a schedule and I had the user inser start date and end date and then hit a button that ran a macro that hid everything outside of that region. Problem is that I don't wan the user to be able to change anything on those sheets, but the macr gave me an error saying it couldn't alter the cells, cause it wa protected. Is there a way that I can have the macro break through th protection? hopefully not as complicated as programming it to type i the password, but if that is what is needed...

System should calulate use tax
Great Plains should be able to calculate and book use taxes, as this is a fairly common occurance for most businesses. In the very least there should be a way for the system to book an accrual for the tax owed. Currently any tax on purchases is added to the vendor's invoice, which is not always the case. The vendor is not always responsible for collecting the tax. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you...

Disabled macros #3
Our company just upgraded to Windows XP and running Excel 2000. Yesterday I wrote some new macros and saved them, today when I try t run them I get the message: "The macros in this project are disabled." I cannot find when or how to enable them. Can anyone help? -- Message posted from http://www.ExcelForum.com Hi MileHigh, > "The macros in this project are disabled." > I cannot find when or how to enable them. Can anyone help?? > Excel is set to high macro security. Set it to medium so you can choose whether to enable them or not: Tools, Macros, securi...

View distribution lists in OWA using Exchange 2003 for a backend
How can I see Distribution Lists along with the Global Address List and Contacts in OWA? We are running Exchange 2003. This is a college and the student/faculty email is accessed only thru OWA. Distribution List were made on the server but how do we view them from OWA? Open the Global Address List, in the Display Name field hit the spacebar once then click find. This should display all of the DLs Dave >-----Original Message----- >How can I see Distribution Lists along with the Global Address List and >Contacts in OWA? We are running Exchange 2003. This is a college and the &g...

Shorten a Macro
Hi All ---- Seasons Greetings Below is a macro I recorded it goes on for 23 Sheets --- I'm only showing the 1st three sheets in the macro--- is there a way of cutting down on all the code that is needed to run the full macro. Sheets("RPRA").Select Columns("E:E").Select Selection.TextToColumns Destination:=Range("G1"), DataType:=xlDelimited, _ TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _ Semicolon:=False, Comma:=True, Space:=False, Other:=True, FieldInfo:= _ Array(Array(1, 1), Array(2, 1), Array...

Who can use custom buttom?
Who can use customer buttom? I create .dll with one class and regist it to POS, I set custom buttom in Store Operation with Style Com Object (session object) but I cannot use it. It popup "Attempt to execute com object "mydll.myclass" failed, Colud not create object". I don't know what is my error. Please recommadation for me. Thanks you for your help That could be caused by several different issues: 1) Your Hook is not correctly entered in the windows registry 2) there is a problem in the signature of your Process() function Public Function Process(session as Obj...

Use outlook to set meeting agenda
We have a fixed weekly executive review meeting - rather than arrange for an agenda each week I want people to be able to reserve a section of the meeting, for themselves. I think that I want a "public" calendar, containing only this 2hr meeting but shown as a series of adjacent pre- defined 20min "slots" that people can "book" using outlook. How do you create this so that it is not "mine"? Ideally, when they pick one of the times, they would enter some detail of the project to be reviewed and these details would be distributed to the attendees b...

Linq to SQL... why not use it?
Friends, I've always just used SQL of my own creation, (often with programmatic fluff), that is ultiamtely sent to SQL Server. Now with Linq, the "text within code" model could be changing. A respected member here stated "do not use LINQ to SQL, unless you are strictly doing stored procedure access. And even then don't use it.", with a smile. Clearly, even with the smile, there is an opinion here, and I'm curious if anybody could elaborate. I am always skeptical of rushing into "the latest thing", but have been brought on to a proj...

Using a VM for failover exchange 2003
Hi this has been brought up in meetings and I have been looking into it a bit, and have read about using a VM for failover for exchange 2003 in the event of a hardware failure. We have a SAN which contains the current exchange databases etc and was wondering if there was any solution out there that would monitor the physical exchange server and in the event of failure start a VM on another machine to provde mail until the physical server can be brought back online? Thanks for any advice Have you looked at a producet called XOsoft? they may do something like what you are looking for N...

Copy and Paste Macro 04-15-10
I am attempting to create a macro to copy and paste. The cells I need to copy are not adjacent to each other. I used the Ctrl key to select the cells but I get an error that it cannot be done. How do I select and copy these non-adjacent cells in a macro? http://j-walk.com/ss/excel/tips/tip36.htm -- Don Guillett Microsoft MVP Excel SalesAid Software dguillett@gmail.com "ABelect" <ABelect@discussions.microsoft.com> wrote in message news:98AECC0F-85E2-4390-98D6-D0CCAEC739FA@microsoft.com... >I am attempting to create a macro to copy and paste. The cells ...

useing access to create orders
I have all my inventory in access and now i want to create and order form in excel. I want to somehow with ease be able to select from the inventory in access and have it appear on the excel order form. I also want the access database to update the amount being taken out of stock as the item is entered into the excel order form. How do I do this?? Emily Hi Emily Is there are reason why your ae using excell and access. It sound like you would b better using one or the other - and if you have the items in access it would not take much work to process the whole thing in access. Of c...

Macro not working.
this macro doesn't work...it should delete any how that doesn't have "NCG" in column 13, but doesn't work Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Dim lastrow As Long, r As Long lastrow = ActiveSheet.UsedRange.Rows.Count For r = lastrow To 1 Step -1 If UCase(Cells(r, 13).Value) <> "NCG" Then Rows(r).Delete Next r Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True I just tried your code, as posted, and (using XL2003) it works fine for me. Rick "S...

Making New Macros
I am trying to add a macro that will effectivly roll over old statistical information, from one worksheet to the next. As this will be a yearly button, I need it to be able to add this information into the next colum after each use????? iCol = Worksheets("Sheet2").Cells(1,Columns.Count).End(xlToLeft).Column+1 Columns(1).Copy Destination:=Worksheets("Sheet2").Columns(iCol) -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "David" <david.jukes@act.gov.au> wrote...

Print Set-up is using only 10% of Page
I have a large document I am trying to have print out. The data I am printing is forced into about 10% of the page -- in the upper left hand corner -- rather than using the entire space available on the page. As a result, the data is too small to read. I had this document set up to print the way I wanted it -- using the entire page, and then at some point it got corrupted and crammed into the upper left hand corner. This happens to me quite often on this machine and on others. Thanks for any help. Excel 2000, XP. I would guess that on "Page Setup", you have the scaling checke...

IM-Can I use it to update an item?
Hello, Assuming an integrated Inventory Item already exists in GP, if the item description is changed on the source data, can the item be updated through IM? If not, what are my other automated options? Thanks Jerry Yes. You would make your integration insert/update. from the IM integration properties. "Jerry" wrote: > Hello, > Assuming an integrated Inventory Item already exists in GP, if the item > description is changed on the source data, can the item be updated through > IM? If not, what are my other automated options? > Thanks > Jerry > > &...

Important task using visio
Hi, I have a very important presentation to give and am planning to give using visio but however am new to visio environment. Thepresentation is about say the task carried by 2 companies during a project that is the 2 companies share different responsibilities during project implementation The flow is: Comany A Task 1 Comapany B Task 2 Task 3 Company A Task 4 Company B Task 5 Task 6 The flow can be analogous to a computer program flow Can anyone help me how 2 implement in visio?? Hello Raj, There's the main Visio 2007 Help and How-to page over here: http://office.microsof...

Using PivotTables with > 65,000 rows
I am trying to create a PivotTable that will query data that exceed 65,000 rows (250,000 rows to be more exact). However, no idividua user will ever need to display more than 25,000 rows. Is there a way that I can have the 250,000 rows of data avialable i Excel (or Microsoft Query), but not displayed? Then when the use selects their critieria, only the total rows that meet their reques would be displayed? Thanks for your help! Jaso -- Message posted from http://www.ExcelForum.com You can create the pivot table from the external source, but it will be subject to the PivotTable limitatio...

Can the Manual Duplex Add-in be used with Postcards?
I downloaded the plugin to help me out of a fustrating situation. I have created a postcard, and wish to print it full-bleed, four to a sheet. However, my printer (Canon i9100) for reasons best known to itself, won't allow duplex printing when full bleed is selected but, if I don't select full bleed (and it's not 'full' full-bleed, either, it's only 25% - full bleed is a sliding scale) the wording at the bottom of the card is cut off (and it doesn't matter what the point size is). I'm sure in the previous revision of the driver this wasn't an issue, but I ca...

Macro's of a signature
Can I make a macro to insert my signature with a key stroke instead of going down through the pull downs? I have a number of different signatures that i like to use and going through the pull-downs is to long. I need a faster way of doing this. I looked a macros in the help but didn't see an easy way of making one? Anyone have a suggestion? TIA, Scott See this code: http://www.outlookcode.com/codedetail.aspx?id=615 -- Ricardo Silva [Outlook MVP] http://www.rsoutlook.com/us/home.html ...