Solved

VB issues in excel 2007

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
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.
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 …
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…

947 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now