Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro running in excel. it has to check some automatic updated
numbers each minute. When there is a problem with the numbers it gives a message - but when there is no problem i do not want to see anything. It works fine when I work in other spreadsheets in Excel (nothings happens except when it should) - but if I work in Word, Outlook or so Excel takes focus everytime the macro runs. Pretty annoing when you write something and suddenly writes in Excel instead of word.... |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Rul
Send the last bit of your code. Regards JY "RUL" wrote in message ... I have a macro running in excel. it has to check some automatic updated numbers each minute. When there is a problem with the numbers it gives a message - but when there is no problem i do not want to see anything. It works fine when I work in other spreadsheets in Excel (nothings happens except when it should) - but if I work in Word, Outlook or so Excel takes focus everytime the macro runs. Pretty annoing when you write something and suddenly writes in Excel instead of word.... |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Overvaegning()
Besked = "" i = ThisWorkbook.Sheets("Strakskurs").Range("P12_start ").Row Startraekke = ThisWorkbook.Sheets("Strakskurs").Range("P12_start ").Row For i = Startraekke To Startraekke + 13 MaxForskel = ThisWorkbook.Sheets("Strakskurs").Range("X" & i).Value Forskel_bid = ThisWorkbook.Sheets("Strakskurs").Range("M" & i).Value - ThisWorkbook.Sheets("Strakskurs").Range("Y" & i).Value Forskel_ask = ThisWorkbook.Sheets("Strakskurs").Range("n" & i).Value - ThisWorkbook.Sheets("Strakskurs").Range("Z" & i).Value If Abs(Forskel_bid) MaxForskel Or Abs(Forskel_ask) MaxForskel Then xxxx a (long) message is written xxxxxxx End if Next 'Only goes to this loop if a warning is sent If Besked < "" Then 'så skal der sendes advarsel Besked = Besked & " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx" Besked = Besked & Chr(13) & Chr(13) & "Timeren stoppes nu - du skal selv starte den igen, når fastkurs er opdateret med nye kurser" test = MsgBox(Besked, vbOKOnly, "FASTKURS AFVIGELSE") Exit Sub End If Call timer End sub Timer modul: Public RunWhen As Double Public Const cRunIntervalSeconds = 60 ' 1 minut Public Const cRunWhat = "Overvaegning" Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _ schedule:=True End Sub Everything works as expected - except that excel takes focus from other programs - even thoug no message is sent |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi again,
I tried this Sub test() Application.OnTime Now + TimeValue("00:00:15"), "test2" End Sub Sub test2() Dim test Debug.Print "Hello " & Now Sheet2.Select test = MsgBox("Besked", vbOKOnly, "FASTKURS AFVIGELSE") Debug.Print test End Sub And nothing happend ! So XL did not take the focus. Sorry. Somebody else any ideas ? Regards JY "RUL" wrote in message ... Sub Overvaegning() Besked = "" i = ThisWorkbook.Sheets("Strakskurs").Range("P12_start ").Row Startraekke = ThisWorkbook.Sheets("Strakskurs").Range("P12_start ").Row For i = Startraekke To Startraekke + 13 MaxForskel = ThisWorkbook.Sheets("Strakskurs").Range("X" & i).Value Forskel_bid = ThisWorkbook.Sheets("Strakskurs").Range("M" & i).Value - ThisWorkbook.Sheets("Strakskurs").Range("Y" & i).Value Forskel_ask = ThisWorkbook.Sheets("Strakskurs").Range("n" & i).Value - ThisWorkbook.Sheets("Strakskurs").Range("Z" & i).Value If Abs(Forskel_bid) MaxForskel Or Abs(Forskel_ask) MaxForskel Then xxxx a (long) message is written xxxxxxx End if Next 'Only goes to this loop if a warning is sent If Besked < "" Then 'så skal der sendes advarsel Besked = Besked & " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxx" Besked = Besked & Chr(13) & Chr(13) & "Timeren stoppes nu - du skal selv starte den igen, når fastkurs er opdateret med nye kurser" test = MsgBox(Besked, vbOKOnly, "FASTKURS AFVIGELSE") Exit Sub End If Call timer End sub Timer modul: Public RunWhen As Double Public Const cRunIntervalSeconds = 60 ' 1 minut Public Const cRunWhat = "Overvaegning" Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _ schedule:=True End Sub Everything works as expected - except that excel takes focus from other programs - even thoug no message is sent |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to save Excel, using macro which takes the name from a cell contained in it? | Excel Worksheet Functions | |||
opening different programs with excel macro buttons | Excel Worksheet Functions | |||
Time Calculation - How long a macro takes to run | Excel Programming | |||
Counting how long a Macro takes to run | Excel Programming | |||
Excel VBA - Executing external programs in an excel macro | Excel Programming |