LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
YH YH is offline
external usenet poster
 
Posts: 18
Default Need help from Excel and SAP expert!

I need a micro that runs a vbs script to export data to SAP, waits for the
SAP data export to complete, saves the exported data in a new worksheet, and
goes back to SAP screen. However, my micro (attached below) has these
problems:

1) When running wscript.exe to execute vbs code, a wscript logon window pops
up.
How can I remove the pop-up?
2) Excel does not wait for SAP to finish exporting. It automatically runs
the next line.
3) Once the exported data is saved in excel format, how can I make the micro
return to original SAP window?

Any help is greatly appreciated.

Thanks,
YH



Declare Function OpenProcess Lib "Kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long


Declare Function GetExitCodeProcess Lib "Kernel32" _
(ByVal hProcess As Long, _
lpExitCode As Long) As Long


Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103

Sub VF()
Dim StartTime As Double
Dim retval As Variant

retval = Shell("c:\windows\system32\wscript.exe C:\VF.vbs", vbNormalFocus)
ShellAndWait "c:\windows\system32\wscript.exe", 1
'ShellAndWait does not wait for VF.vbs to finish and runs the next line!
Need help.
MsgBox "file download complete"
ActiveWorkbook.SaveAs Filename:="C:\REV.xls"

'When SAP exports data to excel, it by default exports a worksheet called
"Worksheet
'in Basis(1)". Here is to delete the worksheet since I already saved it as
REV.xls.

Windows("Worksheet in Basis (1)").Close

End Sub

'Window States (Per Help for Shell function):
' 1, 5, 9 Normal with focus.
' 2 Minimized with focus.
' 3 Maximized with focus.
' 4, 8 Normal without focus.
' 6, 7 Minimized without focus.
Sub ShellAndWait(ByVal PathName As String, Optional WindowState)
Dim hProg As Long
Dim hProcess As Long, ExitCode As Long

'fill in the missing parameter and execute the program
If IsMissing(WindowState) Then WindowState = 1
hProg = Shell(PathName, WindowState)
'hProg is a "process ID under Win32. To get the process handle:
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProg)
Do
'populate Exitcode variable
GetExitCodeProcess hProcess, ExitCode
DoEvents
Loop While ExitCode = STILL_ACTIVE
End Sub



 
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
MOS Excel Expert 2003 Fowmy New Users to Excel 2 January 6th 11 10:22 PM
how to become a microsoft excel expert innovative New Users to Excel 6 November 18th 09 07:52 PM
Urgent help from all excel expert ! brandonb Excel Programming 4 March 17th 06 10:24 AM
Microsoft Excel Expert ???? BaLi - X Excel Programming 0 June 22nd 05 06:40 PM
Excel Expert James Fok Excel Programming 0 October 21st 03 02:52 AM


All times are GMT +1. The time now is 04:20 AM.

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"