Hello Guest it is April 26, 2024, 09:09:47 AM

Author Topic: trying to get writeprivateprofilestring running in a macro  (Read 2123 times)

0 Members and 1 Guest are viewing this topic.

Offline TPS

*
  •  2,505 2,505
    • View Profile
trying to get writeprivateprofilestring running in a macro
« on: July 25, 2012, 05:32:17 AM »
hello,

i have written a small macro to write values into a file.

macro:
Code: [Select]
'Funktion zum schreiben in INI Datei
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal LpString As Any, ByVal lpFileName As String) As Long

Sub Main()
' -------------------------------------------------------------------------------
' TPS 25.07.2012 
' Der im P-Parameter übergebene Wert wird für Werkzeug im Q Parameter im Configfile abgelegt
' -------------------------------------------------------------------------------
'beim Laden des Files Abbrechen
If IsLoading() Then
    GoTo Ende
End If

'Übergebene Parameter holen------------------------------------------------------
ZWert    = Param1()
Werkzeug = Param2()
'--------------------------------------------------------------------------------

Dim File    As String
Dim Sektion As String
Dim Eintrag As String
Dim Wert    As String
Dim n       As Long

'Parameter festlegen ------------------------------------------------------------
File    = "C:\Platemaster\Config.txt"
Sektion = "Werkzeuglaengen"
Eintrag = CStr(Werkzeug)
Wert    = CStr(ZWert)
'--------------------------------------------------------------------------------

'Wert schreiben
n = WritePrivateProfileString(Sektion, Eintrag, Wert, File)

'MsgBox (CStr(n))

Ende:
End Sub


tryed for a couple of hours to get it work.
only the file is created but nothing is written.using the same function in VB6 and ist working fine.
probably somebody has an idea, because i  am out of ideas now.

thanks Thomas

anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.