Refreshing Data

Started by kiler40, November 12, 2014, 08:52:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yacine

Andrei,
How frustrating and exhilarating at the same time. I just made a parallel between your problem and one of mine.
There are many entities linked to a certain status (configuration in your case) and they need to be shown one after the other.
In my previous attempts, I set up quite heavy databases and code to switch from one status to the next.
Your approach is so much lighter and straight forward.
I tried it and it WORKS!
Thank you.


In my case I try to highlight the status of a process line (pipeworks, valves and pumps) according to either a certain sequence or a state of the process line.
I make some snapshots (automatically) of the drawing and comment the picture).
Yacine

kiler40

He he :)
You are welcome ! You know - some times the best idea comes from the stupid :D

And I still haven't figured out how to wait until all shapes on the page receive information from the data...

Yacine

Have you tried the code I posted previously?

DoEvents
Do
Loop Until
Yacine

kiler40

I don`t know how to implement it.
I don`t have problem with save.
on the page there is a blue rectangle that must show letter and number.
when is selected in the shape data it says that this is connector 999
the problem is with this shape. the macro exports to PDF too fast, and this shape is not getting the letter and number.
It stays "0"
Interesting part is that name of exported file is the text from this shape.... :/
I don`t know how to explain it :( Sorry.

I tried GoTo
Something like

Line1:
If shape.cells(prop.connector) = 0 then
goto line1
else
end if

And it stops. the sape stays with 0 and it continues to return to line1


Nikolay

The suggestion from the Yacine should work fine - try "DoEvents" before export, it should do the trick. This VBA function is equivalent to the Application.DoEvents in .NET, or just pumping windows message loop until there are no messages (in principle). Visio processes messages & events using the Windows message queue.

Also, you could try the following approach:
Subscribe to the "ApplicationIdle" (or "NoEventsPending" which may come earlier) event and do your pdf export from that even handler.

Yacine

Hi Andrei

the doevents command allows to enter a loop without loosing control over the application.

In your case the code could look something like:

Public R4S_udated As Boolean
Public S4S_udated As Boolean

Sub RUN_R4S()
unlinkAll
clear_R4S
refresh_R4S
link_R4S 'this Sub must set R4S to true
Do
    DoEvents
Loop Until r4s_updated
ExportToPDF1
r4s_updated = False
NEXT_R4S
End Sub
Yacine

kiler40

It loops and not doing anything. Something is wrong :/

Yacine

Sure! It waits for R4S_updated to become true.
You need to set this variable to true at the end of the previous routine. ie, when the job is finished.
I'm not sure if it is enough to write an assignment at the end of the sub-routine, or if you need to check for a "recordset updated"-something. Please google this by yourself.
Yacine