Avatar billede darth-domino Nybegynder
06. juli 2005 - 13:19 Der er 1 kommentar og
1 løsning

KOpier FIler og Kør program?

Jeg har et lille program der henter nogen filer fra en anden computer, "Installer" dem et valgt sted. Og derefter skal den køre en af filerne som den lige har hentet!

MEN, den skal først starte EFTER at alle filerne er kopieret! Hvordan får jeg den til det??


Jeg bruger denne kode her:
---------------
Dim sti As String
Dim ExcelApp As Excel.Application

sti = "xcopy /E DATA C:\MCAU\DATA\"
Shell sti, vbHitResultClose
On Error Resume Next

Set ExcelApp = Excel.Application
ExcelApp.Workbooks.Open ("C:\MCAU\Data\Projektmapper\MCAU-menu EJMA 8-1-5.xls")
ExcelApp.Visible = True

End
--------------------
Avatar billede sjh Nybegynder
06. juli 2005 - 15:04 #1
'---------------------------------- Form1 ----------------------------------
Option Explicit

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Const SYNCHRONIZE As Long = &H100000

Private Sub ShellAndWait(strFile As String, Optional intStyle As VbAppWinStyle = vbNormalFocus)
Dim hShell As Long
Dim hProcess As Long
Dim hSuccess As Long

  hShell = Shell(strFile, intStyle)
  hProcess = OpenProcess(SYNCHRONIZE, 0, hShell)
  If hProcess <> 0 Then
    Do
      hSuccess = WaitForSingleObject(hProcess, 0&)
      If hSuccess = 0 Then
        CloseHandle hProcess
        Exit Do
          Else
        DoEvents
        Call Sleep(100)
      End If
    Loop
  End If
End Sub

Private Sub Command1_Click()
Dim sti As String
Dim ExcelApp As Excel.Application

  sti = "xcopy /E DATA C:\MCAU\DATA\"
  ShellAndWait sti, vbHide ' <- ShellAndWait

  Set ExcelApp = Excel.Application
  ExcelApp.Workbooks.Open ("C:\MCAU\Data\Projektmapper\MCAU-menu EJMA 8-1-5.xls")
  ExcelApp.Visible = True
End Sub
'---------------------------------- Form1 ----------------------------------
Avatar billede sjh Nybegynder
09. juli 2005 - 20:08 #2
når hvad siger du til det??
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester