Microsoft Excel: VB code running thats loads SQL script but once running can't use computer.
Posted on 2006-05-10
I am running an Excel spreadsheet that calls 3 different SQL scripts that take about 20mins to run through. When it is running I can not use my machine because the SQL window keeps taking
over. For example when it is running if I click on my Microsoft Outlook I will only have it for about
5 seconds then the SQL window is Live again, I then click on Outlook again but then 5 seconds later the SQL plus window again pops up.
Here is the code I have in Excel I click a command button to run it:
UserName = UCase(Environ("USERNAME"))
UID = "USER_" & UserName
PWD = UserName
DSN = "my_database"
script_file = "C:\my_sql\" & sql_script & ".sql"
cmd = "C:\ORANT\BIN\PLUS80W.EXE " & UID & "/" & PWD & "@" & DSN & " @" & script_file
AppID = Shell(cmd, 6)
On Error GoTo Finished
Do While True
AppActivate "Microsoft Excel"
Sub sleep(Secs As Integer)
Start = Timer
Do While Timer < Start + Secs
Is there a way I can set this thing running and then excel pops up when finished or something like that.