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.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

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



???
 

Forum statistics

Threads
1,141,137
Messages
5,704,490
Members
421,353
Latest member
jekoxien15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top