?
Solved

VB issues in excel 2007

Posted on 2008-10-22
3
Medium Priority
?
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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 …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

801 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