Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RUL RUL is offline
external usenet poster
 
Posts: 2
Default Excel macro takes focus from other programs

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default Excel macro takes focus from other programs

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   Report Post  
Posted to microsoft.public.excel.programming
RUL RUL is offline
external usenet poster
 
Posts: 2
Default Excel macro takes focus from other programs

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default Excel macro takes focus from other programs

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to save Excel, using macro which takes the name from a cell contained in it? [email protected] Excel Worksheet Functions 1 September 6th 06 04:43 PM
opening different programs with excel macro buttons shrek Excel Worksheet Functions 0 September 30th 05 12:41 PM
Time Calculation - How long a macro takes to run cdb Excel Programming 7 March 31st 05 08:51 AM
Counting how long a Macro takes to run Diane Alsing Excel Programming 2 February 7th 05 05:41 PM
Excel VBA - Executing external programs in an excel macro schumacker Excel Programming 1 February 24th 04 12:17 PM


All times are GMT +1. The time now is 03:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"