Wait until query web page display ?

danial

Board Regular
Joined
Apr 29, 2006
Messages
107
Sawasdee,

I created script(macro) for import external data by "New Web Query..."
and I want to calculate data from qry data.
While excel getting data from web(do not display yet), script next step has been run.

How can I create script for wait it ?
I'm try with code
Code:
Application.wait
but it not work.

should you have any way for me.
thank a lot.
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Daniel

you need to loop until the readystate = 4

I don't know how you have got to the web, but this may set you in the right direction.

Code:
Dim IExp As Object
  Set IExp = CreateObject("internetexplorer.application")
  IExp.navigate "http:yourURL"
'make sure the screen is fully activated
  Do Until IExp.readystate = 4
    DoEvents
  Loop


Tony
 

danial

Board Regular
Joined
Apr 29, 2006
Messages
107
I import data from web query by code below

Code:
        With ActiveSheet.QueryTables.Add(Connection:= _
            "URL;http://10.20.206.84/Hrcharter/Job.asp?key=" & PPID, Destination:=Range("A1"))
            .Name = "JobKey"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = False
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .WebSelectionType = xlEntirePage
            .WebFormatting = xlWebFormattingNone
            .WebPreFormattedTextToColumns = True '?
            .WebConsecutiveDelimitersAsOne = True
            .WebSingleBlockTextImport = False
            .WebDisableDateRecognition = False
            .WebDisableRedirections = False
            .Refresh BackgroundQuery:=True
        End With
<recored by macro>

I'm nut sure that I will apply from "IExp.readystate = 4" (how to)
or set something properties
 

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

Doing it that way, try changing the refresh line to

.Refresh BackgroundQuery:=False

I think that will force the code to wait until the data is extracted.


Tony
 

MarkAndrews

Well-known Member
Joined
May 2, 2006
Messages
1,963
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime



???
 

Watch MrExcel Video

Forum statistics

Threads
1,109,032
Messages
5,526,355
Members
409,697
Latest member
christopherlewis1620

This Week's Hot Topics

Top