Supportnet / Forum / Skripte(PHP,ASP,Perl...)
VBA: Problem mit Abfrage, ob eine Auswahl (Selection) stattgefunden hat
Frage
Hallihallo!
Ich bin gerade dabei ein VBA-Word Makro zu schreiben, in dem ich u.a. abfragen muss ob ein Textbereich ausgewählt wurde. Meine Lösung sieht folgendermaßen aus:
[code]
If Selection.Text = "" Then
MsgBox "You have to select the textarea you want to export! ", vbInformation, "Select Text!"
Else
´End If
´If Selection.Text <> "" Then
Selection.Copy
Documents.Add Template:="Normal", NewTemplate:=False, _
DocumentType:=0
Selection.Paste
End If
[/code]
Jetzt bekomme ich immer, wenn ich nichts auswähle die Fehlermeldung dass nichts ausgewählt wurde und beim debuggen springt er zur zeile (im ELSE-Zweig!!) Selection.Copy, wo er eigentlich gar nicht hingelangen dürfte.
Was hab ich denn da falsch gemacht?
LG
nine.
Antwort 1 von Event
Hallo
Habs g´rade mal probiert mit Word2000 (9)
Seltsamerweise ist Selection.Text Nie leer ( "" ).
aber so sollte es funktionieren
Gruß
Habs g´rade mal probiert mit Word2000 (9)
Seltsamerweise ist Selection.Text Nie leer ( "" ).
If Len(Selection.Text) < 2 Then
MsgBox "You have to select the textarea you want to export! ", vbInformation, "Select Text!"
Else
End If
Debug.Print Asc(Selection.Text)
If Len(Selection.Text) >= 2 Then
Selection.Copy
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
Selection.Paste
End If
End Sub
aber so sollte es funktionieren
Gruß

