Solved

VB issues in excel 2007

Posted on 2008-10-22
3
198 Views
Last Modified: 2012-05-05
Hi,

This works fine with excel 2003, but now I´m moving to excel 2007 and don´t know how to change "filesearch" code.

Task the macro does:

loking "c:\consultas\" folder and subfolders
File type: excel file (xls, xlsx, etc) ONLY EXCEL FILES
pt.PivotCache.MissingItemsLimit = xlMissingItemsNone (change a property)

ActiveWorkbook.RefreshAll => VERY IMPORTANT, I THINK THIS IS WORKING FINE, REFRESH PIVOT TABLE
ActiveWorkbook.Save
ActiveWorkbook.Close

I THINK THE ONLY THING THAT IS NOT WORKING IS "APPLICATION.FILESEARCH

Thanks,
akiles
Private Sub Workbook_Open()
Application.DisplayAlerts = False
On Error Resume Next
Dim basebook As Workbook
Dim mybook As Workbook
Dim pt As PivotTable
Dim ws As Worksheet
With Application.FileSearch **** here is the problem
.NewSearch
.LookIn = "C:\Consultas\"
.SearchSubFolders = True
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Set mybook = Workbooks.Open(.FoundFiles(i), UpdateLinks:=0, IgnoreReadOnlyRecommended:=True, corruptload:=0)
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.PivotCache.MissingItemsLimit = xlMissingItemsNone
Next pt
Next ws
ActiveWorkbook.RefreshAll
ActiveWorkbook.Save
ActiveWorkbook.Close
Next i
End If
End With
Application.Quit
End Sub

Open in new window

0
Comment
Question by:akiles99
  • 2
3 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 22782927
The FileSearch object was removed in Excel 2007.

Here is a discussion of alternative solutions:

Title: Application.FileSearch is gone in Excel 2007 -- Alternatives
Link: http://www.mrexcel.com/forum/showthread.php?t=268046

Kevin
0
 

Author Comment

by:akiles99
ID: 22784776
I read it but i can't find how to include that snippet into mine...
0
 

Author Closing Comment

by:akiles99
ID: 31509051
Thanks
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question