Anzeige
Archiv - Navigation
676to680
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
676to680
676to680
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Word-Code in Excel konvertieren

Word-Code in Excel konvertieren
08.10.2005 16:40:45
andreas
Hallo...,
könntet ihr mir bitte folgenden Code für Excel ändern? Ich schaffe es einfach nicht. :-(
Private INIIntern As String

Private Sub UserForm_Activate()
INIIntern = "C:\Dok1.ini"
For Each x In Me.Controls 'Alle Schaltflächen auf der UserForm schleifen
If TypeOf x Is MSForms.OptionButton Or _
TypeOf x Is MSForms.CheckBox Or _
TypeOf x Is MSForms.TextBox Then
tmp = ZUE(0, System.PrivateProfileString(FileName:=INIIntern, _
Section:=Me.Name, Key:=x.Name))
If TypeOf x Is MSForms.TextBox Then 'Klartext
x.Text = tmp
Else
If IsNumeric(tmp) Then x.Value = Int(tmp) 'Boolean
End If
End If
Next
End Sub


Private Sub UserForm_Terminate()
For Each x In Me.Controls
If TypeOf x Is MSForms.OptionButton Or _
TypeOf x Is MSForms.CheckBox Or _
TypeOf x Is MSForms.TextBox Then
If TypeOf x Is MSForms.TextBox Then
tmp = ZUE(1, x.Text) 'Klartext
Else
tmp = Int(x.Value) 'Boolean
End If
System.PrivateProfileString(FileName:=INIIntern, _
Section:=Me.Name, Key:=x.Name) = tmp
End If
Next
End Sub


Private Function ZUE(Richtung As Long, strT As String) As String
'Konvertiert Zeilenumbrüche in X'FF' und umgekehrt
If Richtung = 0 Then 'X'FF' nach Zeilenschaltung
ofs = InStr(strT, Chr(255))
While ofs > 0
strT = Left(strT, ofs - 1) & vbCrLf & Right(strT, Len(strT) - ofs)
ofs = InStr(strT, Chr(255))
Wend
Else 'Zeilenschaltung nach X'FF'
ofs = InStr(strT, Chr(13))
While ofs > 0
strT = Left(strT, ofs - 1) & Chr(255) & Right(strT, Len(strT) - ofs - 1)
ofs = InStr(strT, Chr(13))
Wend
End If
ZUE = strT
End Function

Danke für eure Hilfe.
Und tschüß
andreas

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Word-Code in Excel konvertieren
08.10.2005 17:15:33
Fred
Hi,
Verweis auf die Wordbibliothek setzen und MSForms ändern in Forms
mfg Fred
AW: Word-Code in Excel konvertieren
09.10.2005 11:18:23
Nepumuk
Hi,
versuch es mal so:
Option Explicit

Private INIIntern As String, wdApp As Object

Private Sub UserForm_Activate()
    INIIntern = "C:\Dok1.ini"
    Dim x As Control, tmp As String
    Set wdApp = CreateObject("word.application")
    For Each x In Me.Controls 'Alle Schaltflächen auf der UserForm schleifen
        If TypeOf x Is MSForms.OptionButton Or _
            TypeOf x Is MSForms.CheckBox Or _
            TypeOf x Is MSForms.TextBox Then
            tmp = ZUE(0, wdApp.System.PrivateProfileString(Filename:=INIIntern, _
                Section:=Me.Name, Key:=x.Name))
            If TypeOf x Is MSForms.TextBox Then 'Klartext
                x.Text = tmp
            Else
                If IsNumeric(tmp) Then x.Value = Int(tmp) 'Boolean
            End If
        End If
    Next
End Sub


Private Sub UserForm_Terminate()
    Dim x As Control, tmp As String
    For Each x In Me.Controls
        If TypeOf x Is MSForms.OptionButton Or _
            TypeOf x Is MSForms.CheckBox Or _
            TypeOf x Is MSForms.TextBox Then
            If TypeOf x Is MSForms.TextBox Then
                tmp = ZUE(1, x.Text) 'Klartext
            Else
                tmp = Int(x.Value) 'Boolean
            End If
            wdApp.System.PrivateProfileString(Filename:=INIIntern, _
                Section:=Me.Name, Key:=x.Name) = tmp
        End If
    Next
    Set wdApp = Nothing
End Sub

Private Function ZUE(Richtung As Long, strT As String) As String
    Dim ofs As Integer
    'Konvertiert Zeilenumbrüche in X'FF' und umgekehrt
    If Richtung = 0 Then 'X'FF' nach Zeilenschaltung
        ofs = InStr(strT, Chr(255))
        While ofs > 0
            strT = Left(strT, ofs - 1) & vbCrLf & Right(strT, Len(strT) - ofs)
            ofs = InStr(strT, Chr(255))
        Wend
    Else 'Zeilenschaltung nach X'FF'
        ofs = InStr(strT, Chr(13))
        While ofs > 0
            strT = Left(strT, ofs - 1) & Chr(255) & Right(strT, Len(strT) - ofs - 1)
            ofs = InStr(strT, Chr(13))
        Wend
    End If
    ZUE = strT
End Function

Gruß
Nepumuk

Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige