Solved

VB issues in excel 2007

Posted on 2008-10-22
3
197 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

803 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