Nun kann es aber sein, dass man aber dennoch die Variableneingabe haben möchte und das wiederum geht nicht mit der Seriendruckdatei.
Hier stelle ich nun einmal kurz vor, wie man auf ganz einfache Weise die INI-Variablen lesen und ändern kann. So kann man z. B. den PS-Titel auslesen und in Abhängigkeit davon, die Variablenvorgaben dynamisch gestalten. Somit kann man gezielt den Programmablauf auf seine Bedürfnisse erweitern.
Wie man den PS-Titel auslesen und parsen kann, habe ich ja schon einmal gezeigt.
Hier also nun eine andere Variante für ein PlugIn:
do i=i+1 sResult=ReadIni( "C:UsersAhmedAppDataLocalFreePDF_MultidocFreePDF_Multidoc.ini", "Eingabevariablen", cstr(i) )
'WScript.Echo sResult ' Datei;;0
sINI=Split(sResult,";") If sINI(0)="Datei" then sINI(1)="Mein Neuer Wert" WriteIni "C:UsersAhmedAppDataLocalFreePDF_MultidocFreePDF_Multidoc.ini", "Eingabevariablen", cstr(i), sINI(0) & ";" & sINI(1) & ";" & sINI(2) exit do End If loop while Trim(sResult) ""
'Hilfsfunktionen:
Function ReadIni( myFilePath, mySection, myKey ) ' This function returns a value read from an INI file ' ' Arguments: ' myFilePath [string] the (path and) file name of the INI file ' mySection [string] the section in the INI file to be searched ' myKey [string] the key whose value is to be returned ' ' Returns: ' the [string] value for the specified key in the specified section ' ' CAVEAT: Will return a space if key exists but value is blank ' ' Written by Keith Lacelle ' Modified by Denis St-Pierre and Rob van der Woude
If objFSO.FileExists( strFilePath ) Then Set objIniFile = objFSO.OpenTextFile( strFilePath, ForReading, False ) Do While objIniFile.AtEndOfStream = False strLine = Trim( objIniFile.ReadLine )
' Check if section is found in the current line If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then strLine = Trim( objIniFile.ReadLine )
' Parse lines until the next section is reached Do While Left( strLine, 1 ) 0 Then strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) ' Check if item is found in the current line If LCase( strLeftString ) = LCase( strKey ) Then ReadIni = Trim( Mid( strLine, intEqualPos + 1 ) ) ' In case the item exists but value is blank If ReadIni = "" Then ReadIni = " " End If ' Abort loop when item is found Exit Do End If End If
' Abort if the end of the INI file is reached If objIniFile.AtEndOfStream Then Exit Do
' Continue with next line strLine = Trim( objIniFile.ReadLine ) Loop Exit Do End If Loop objIniFile.Close Else WScript.Echo strFilePath & " doesn't exists. Exiting..." Wscript.Quit 1 End If End Function
Sub WriteIni( myFilePath, mySection, myKey, myValue ) ' This subroutine writes a value to an INI file ' ' Arguments: ' myFilePath [string] the (path and) file name of the INI file ' mySection [string] the section in the INI file to be searched ' myKey [string] the key whose value is to be written ' myValue [string] the value to be written (myKey will be ' deleted if myValue is ) ' ' Returns: ' N/A ' ' CAVEAT: WriteIni function needs ReadIni function to run ' ' Written by Keith Lacelle ' Modified by Denis St-Pierre, Johan Pol and Rob van der Woude
Dim blnInSection, blnKeyExists, blnSectionExists, blnWritten Dim intEqualPos Dim objFSO, objNewIni, objOrgIni, wshShell Dim strFilePath, strFolderPath, strKey, strLeftString Dim strLine, strSection, strTempDir, strTempFile, strValue
' Check if path to INI file exists, quit if not strFolderPath = Mid( strFilePath, 1, InStrRev( strFilePath, "" ) ) If Not objFSO.FolderExists ( strFolderPath ) Then WScript.Echo "Error: WriteIni failed, folder path (" _ & strFolderPath & ") to ini file " _ & strFilePath & " not found!" Set objOrgIni = Nothing Set objNewIni = Nothing Set objFSO = Nothing WScript.Quit 1 End If
While objOrgIni.AtEndOfStream = False strLine = Trim( objOrgIni.ReadLine ) If blnWritten = False Then If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then blnSectionExists = True blnInSection = True ElseIf InStr( strLine, "[" ) = 1 Then blnInSection = False End If End If
If blnInSection Then If blnKeyExists Then intEqualPos = InStr( 1, strLine, "=", vbTextCompare ) If intEqualPos > 0 Then strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) If LCase( strLeftString ) = LCase( strKey ) Then ' Only write the key if the value isn't empty ' Modification by Johan Pol If strValue "" Then objNewIni.WriteLine strKey & "=" & strValue End If blnWritten = True blnInSection = False End If End If If Not blnWritten Then objNewIni.WriteLine strLine End If Else objNewIni.WriteLine strLine ' Only write the key if the value isn't empty ' Modification by Johan Pol If strValue "" Then objNewIni.WriteLine strKey & "=" & strValue End If blnWritten = True blnInSection = False End If Else objNewIni.WriteLine strLine End If Wend
If blnSectionExists = False Then ' section doesn't exist objNewIni.WriteLine objNewIni.WriteLine "[" & strSection & "]" ' Only write the key if the value isn't empty ' Modification by Johan Pol If strValue "" Then objNewIni.WriteLine strKey & "=" & strValue End If End If
objOrgIni.Close objNewIni.Close
' Delete old INI file objFSO.DeleteFile strFilePath, True ' Rename new INI file objFSO.MoveFile strTempFile, strFilePath
Set objOrgIni = Nothing Set objNewIni = Nothing Set objFSO = Nothing Set wshShell = Nothing End Sub
Ihr müsst einfach nur diesen Code als VBSript speichern und als PlugIn einbinden. Jetzt wird dann jedes Mal der Variablenwert dynamisch geändert werden. Natürlich kann man auch Comboxwerte vorgeben. Bitte achtet nur dann auf die Anzahl der Semikolon's [;].
Solltet Ihr noch Fragen haben, dann einfach hier melden.
Gruß Ahmed
FreePDF_Multidoc (PS2PDF mit vielen Optionen f. FreePDF) File2PDF (komplette Verzeichnisse auf einen Streich umwandeln) findest Du alles hier: http://amTools.de