We help IT Professionals succeed at work.
Get Started

Opening Multiple IQY Files for full-page queries, saving one cell

Last Modified: 2017-04-03
I used a previous expert's answer from Excel 2003, but it doesn't seem to work for 2013.

I have a directory with multiple IQY files. Each one is for an intranet page which has data I need, but isn't broken up into tables. The IQY for each page is set to pull the entire page's data and insert it into column A.

Of all of these cells, I only need one (Cell A159).

I was using:

Sub OpenAllIQY()
Dim FName As String, Path As String
  Path = "C:\Users\jjar\Documents\My Data Sources\"
  FName = Dir(Path & "*.iqy")
  While Len(FName) > 0
    OpenIQY Path & FName
    FName = Dir
    Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) + 5)
End Sub
Sub OpenIQY(IQYName)
Dim WBN As Workbook
  Set WBN = Application.Workbooks.Add
  With WBN.Worksheets(1).QueryTables.Add(Connection:= _
    "FINDER;" & IQYName, Destination:=WBN.Worksheets(1).Range("A1"))
    .Name = "IQY"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = False
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlAllTables
    .WebFormatting = xlWebFormattingNone
    .WebPreFormattedTextToColumns = False
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
  End With
  WBN.Close SaveChanges:=True, Filename:=Replace(IQYName, ".iqy", "", , , vbTextCompare)
End Sub

To open each IQY file and save the search as an Excel file, which I could then open into workbooks and call the specific cell I needed from each of them into one master workbook. Unfortunately, when I run the above macro, the Excel Files it saves (using my IQY files) are empty.

Even if this were to work, there has to be a more efficient way.
Watch Question
PowerPoint Technical Consultant
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE