[VBscript] Do.. loop..

Pagina: 1
Acties:

  • ArjanC
  • Registratie: Juli 2001
  • Laatst online: 26-01 17:16
okee, ik beken.. ben een n00b met VBscript.
heb wel ASP gedaan, maar toch om de een of andere reden kom ik er niet uit..

ik heb dit scriptje :
code:
1
2
3
4
5
6
7
8
dim objOL
Set objOL = GetObject(, "Outlook.Application")
do while ObjOl is nothing 
msg = "Outlook is open, please close outlook first"   
style = Vbokonly
title = "Microsoft Outlook is open" 
response = MsgBox(msg, style, title)
loop

okee. als ik outlook open heb staan geeft hij een box, maar sluit ik outlook af geeft hij nog steeds die box.
dit is alleen maar als ik outlook afsluit tijdens dit boxje.

nu had ik er dit tussengezet SET ObjOl = Noting
mocht niet baten.

  • mulder
  • Registratie: Augustus 2001
  • Laatst online: 09:50

mulder

ik spuug op het trottoir

Ten eerste staat do while ObjOl is Nothing. Doe zolang niets is niets dus.

Volgens mij throwt GetObject ook een error als Outlook niet is opgestart, zo zou je ook kunnen checken.

oogjes open, snaveltjes dicht


  • Crayne
  • Registratie: Januari 2002
  • Laatst online: 17-03-2025

Crayne

Have face, will travel

Op maandag 22 juli 2002 15:31 schreef burp2001 het volgende:
code:
1
2
3
4
5
6
7
8
dim objOL
Set objOL = GetObject(, "Outlook.Application")
do while ObjOl is nothing 
msg = "Outlook is open, please close outlook first"   
style = Vbokonly
title = "Microsoft Outlook is open" 
response = MsgBox(msg, style, title)
loop
Volgens mij is de benaming van je variabelen heel belangrijk.

Je gebruikt set objOl en vervolgens kijk je of ObjOl nothing is. Tuurlijk is die nothing, want dat is niet de variabele die je geSET hebt.

* Crayne hoopt dat hij niet uit zijn aars loopt te blaten

Mijn Library Thing catalogus


  • ArjanC
  • Registratie: Juli 2001
  • Laatst online: 26-01 17:16
okee, gotcha..

ander scriptje gecreert (met de goeie naampjes)
code:
1
2
3
4
5
6
7
8
9
10
11
12
dim ObjOL

Set ObjOL = GetObject(, "Outlook.Application")

do until ObjOl is nothing 
    WSHShell.run "wscript.exe \\rtmeur01\apps\backup\backup_ost.vbs /full",1,true  
else
    msg = "Outlook is open, please close outlook first"   
    style = Vbokonly
    title = "Microsoft Outlook is open" 
    response = MsgBox(msg, style, title)
loop

doet het niet :(

  • [ash]
  • Registratie: Februari 2002
  • Laatst online: 23-08 12:03

[ash]

Cookies :9

moet die:
code:
1
Set ObjOL = GetObject(, "Outlook.Application")

niet in de do...while loop ??

  • ArjanC
  • Registratie: Juli 2001
  • Laatst online: 26-01 17:16
hoe dan ??

  • Feyd-Rautha
  • Registratie: November 2001
  • Laatst online: 02-08-2025
Op maandag 22 juli 2002 15:41 schreef burp2001 het volgende:
okee, gotcha..

ander scriptje gecreert (met de goeie naampjes)
code:
1
2
3
4
5
6
7
8
9
10
11
12
dim ObjOL

Set ObjOL = GetObject(, "Outlook.Application")

do until ObjOl is nothing 
    WSHShell.run "wscript.exe \\rtmeur01\apps\backup\backup_ost.vbs /full",1,true  
else
    msg = "Outlook is open, please close outlook first"   
    style = Vbokonly
    title = "Microsoft Outlook is open" 
    response = MsgBox(msg, style, title)
loop

doet het niet :(
huh, wat doet die ELSE daar :?
en die is nothing moet dat niet is null worden ofzo.

set Object is nothing -
wordt toch enkel gebruikt om het geheugen terug vrij te geven?

I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. Where the fear has gone there will be nothing. Only I will remain.


  • ArjanC
  • Registratie: Juli 2001
  • Laatst online: 26-01 17:16
misschien is er iets mis met mijn logica (zal wel anders deed hij het al :) )

do todat ObjOl leeg is
<doe hier wat hij moet doen als hij leeg is>
anders (else)
<doe dit>
loop
code:
1
2
3
4
5
6
7
8
do until ObjOl is nothing 
msg = &quot;Outlook is open, please close outlook first&quot;   
style = Vbokonly
title = &quot;Microsoft Outlook is open&quot; 
response = MsgBox(msg, style, title)
else
WSHShell.run &quot;wscript.exe \\rtmeur01\apps\backup\backup_ost.vbs /full&quot;,1,true  
loop

werkt niet :(

btw. is nothing werkt.

  • Skinny
  • Registratie: Januari 2000
  • Laatst online: 25-07 18:17

Skinny

DIRECT!

Ik heb hier even geen Outlook voorhanden, maar met Excel werkt onderstaand stukje perfect.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
On Error Resume Next

Dim ExcelRunning As Boolean
Dim objOL As Object

ExcelRunning = True

Do While ExcelRunning

Set objOL = GetObject(, &quot;Excel.Application&quot;)

If Err.Number = 0 Then
    MsgBox &quot;Excel is nog aktief&quot;
    Set objOL = Nothing
    ExcelRunning = True
Else
    ExcelRunning = False
    Err.Clear
    Exit Do
End If

Loop

MsgBox &quot;Nu gaan we verder&quot;

SIZE does matter.
"You're go at throttle up!"


  • Feyd-Rautha
  • Registratie: November 2001
  • Laatst online: 02-08-2025
Ik ben nu ook geen VB-krak, maar volgens mij en alle andere programmeertalen kun je toch geen ELSE zetten zonder een IF ?

... Maar van M$ mogen we alles verwachten natuurlijk :P

I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. Where the fear has gone there will be nothing. Only I will remain.


  • ArjanC
  • Registratie: Juli 2001
  • Laatst online: 26-01 17:16
Op maandag 22 juli 2002 15:54 schreef Skinny het volgende:
Ik heb hier even geen Outlook voorhanden, maar met Excel werkt onderstaand stukje perfect.
[code]On Error Resume Next

Dim ExcelRunning As Boolean
krijg hier al een error op..

As Boolean.. kent ie niet :)

  • Skinny
  • Registratie: Januari 2000
  • Laatst online: 25-07 18:17

Skinny

DIRECT!

En als je die "As Boolean" weglaat ?

[edit]
VBScript (voor WSH) kent dus alleen maar Variant als datatype. Onderstaand script werkt 100% bij mij als .vbs-je
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
On Error Resume Next
Dim ExcelRunning 
Dim objOL 

ExcelRunning = True

Do While ExcelRunning

Set objOL = GetObject(, &quot;Excel.Application&quot;)

If Err.Number = 0 Then
    MsgBox &quot;Excel is nog aktief&quot;
    Set objOL = Nothing
    ExcelRunning = True
Else
    ExcelRunning = False
    Err.Clear
    Exit Do
End If

Loop

MsgBox &quot;Nu gaan we verder&quot;

SIZE does matter.
"You're go at throttle up!"


  • ArjanC
  • Registratie: Juli 2001
  • Laatst online: 26-01 17:16
hehe,

na wat veranderingen werkt hij met Excel!

maar niet met outlook..

als hij met die vraag komt en ik sluit mijn outlook blijft 'ie terugkomen.

  • Skinny
  • Registratie: Januari 2000
  • Laatst online: 25-07 18:17

Skinny

DIRECT!

Hele stomme vraag, maar loopt er niet nog een "hidden" OUTLOOK proces ?

Als je zoveel met die Create/Get-Object funkties zit te spelen, gebeurt het snel dat er een instantie van het desbetreffende programma blijft draaien zonder dat je hem ziet.

Als je 2000/XP hebt, kijk een in je Task Manager onder Processes, of er nog een OUTLOOK.EXE staat te draaien. Anders even een keertje rebooten.

ik heb me er namelijk ooit ook eens in vergist.

SIZE does matter.
"You're go at throttle up!"


  • paulh
  • Registratie: Juli 1999
  • Laatst online: 22-06 15:30
ooops.. laat maar

[ZwareMetalen.com] - [Kom in aktie tegen de CO2 maffia]


  • Greyfox
  • Registratie: Januari 2001
  • Laatst online: 30-08 17:13

Greyfox

MSX rulez

Op maandag 22 juli 2002 15:35 schreef Crayne het volgende:

[..]

Volgens mij is de benaming van je variabelen heel belangrijk.

Je gebruikt set objOl en vervolgens kijk je of ObjOl nothing is. Tuurlijk is die nothing, want dat is niet de variabele die je geSET hebt.
ASP c.q. VBScript is niet case sensitive, dus dat is het probleem niet.

MSX 2 rulez more


  • Skinny
  • Registratie: Januari 2000
  • Laatst online: 25-07 18:17

Skinny

DIRECT!

Sorry hoor, maar af en toe vraag ik me echt wel eens af of mensen uberhaupt een topic lezen voordat ze reply-en.

:(

SIZE does matter.
"You're go at throttle up!"

Pagina: 1