Announcement

Collapse
No announcement yet.

Seltsames Problem

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Seltsames Problem

    Hallo Leute,

    ich habe da ein komisches Problem. Ich rufe mit dem folgenden Code in Word selbst eine Batch-Datei auf und übergebe dieser mit dem Code den Word-Dateinamen.

    Dann transformiert die Batch-Datei die Word-Datei in XML.

    Dann Ganze geht gut. Aber wenn ich vor dem Transformationsaufruf was am Word-Dokument ändere und dann das Word-Dokument abspeichere, findet die Batch-Datei die Word-Datei nicht mehr und der Transformationsprozess kann nicht starten.

    An was liegt das Problem. Warum kann er die Datei nach dem Speichern nicht finden. Sie ist ja da. Wird evtl. eine temporäre Word-Datei angelegt!??

    Wer kann mir helfen. Danke.

    Hier der Word-VBA-Code zum Aufrufen der Batch-Datei:

    Code:
    Option Explicit
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
           (ByVal hwnd As Long, ByVal lpOperation As String, _
            ByVal lpFile As String, ByVal lpParameters As String, _
            ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Sub cmdStartTransform(control As IRibbonControl)
    
    Dim strPath As String
    Dim hwnd As Long
    Dim filename As String
    Const SW_SHOW = 5
    
    strPath = Application.ActiveDocument.Path
    filename = ActiveDocument.Name
    
    ShellExecute hwnd, "open", strPath & "\bin\PI-DOT2MOD_descriptive.bat", filename, 0, SW_SHOW
    
    Sleep 2000
    
    Application.ActiveDocument.Close
    
    End Sub

    Hier der Inhalt der Batch-Datei:
    Mit %1 lese ich in der Batch-Datei den Dateinamen aus, der Word der Batch-Datei übergeben hat.

    Code:
    @ECHO OFF
    
    ECHO PI-DOT2MOD (descriptive module)  -  Copyright (c) 2010, The PI-Mod Project
    ECHO.
    ECHO Starting %1 2 PI-MOD transformation process...
    ECHO.
    ECHO.
    ECHO.
    
    
    REM WAIT 8 SECONDS
    
    @ping -n 8 localhost> nul
    
    
    REM FILE RENAME IN ZIP
    
    rename %1 archive.zip
    
    
    
    REM document.xml EXTRACTION
    
    bin\7za.exe e archive.zip word\document.xml
    
    
    
    REM ZIP RENAME IN FILE
    
    rename archive.zip %1
    
    
    
    REM PI-DOT2MOD TRANSFORMATION
    
    bin\Transform.exe -t -s:document.xml -xsl:bin\descriptive.xsl -o:%1.xml
    
    
    
    REM DELETE document.xml
    
    del document.xml
    
    
    ECHO.
    PAUSE

  • #2
    Hi,
    ich weiß nicht ob sich das nicht längst erledigt hat, aber wenn Du den Befehl
    Code:
    ShellExecute hwnd, "open", strPath & "\bin\PI-DOT2MOD_descriptive.bat", filename, 0, SW_SHOW
    so ausführen willst mußt Du "ShellExecute" als Sub deklarieren, nicht als Function.
    Als Function müsstest Du
    Code:
    ERG = ShellExecute(hwnd, "open", strPath & "\bin\PI-DOT2MOD_descriptive.bat", filename, 0, SW_SHOW)
    schreiben, wobei ERG als Long deklariert ist und das Funktionsergebnis, bei fehlerloser Ausführung also 0, aufnimmt.

    Severus

    Comment

    Working...
    X