Digital-Inn
 
 

Go Back   Digital-Inn > Office-Welt > Visual Basic

Reply
 
Thread Tools Display Modes
Old 16-11-2009   #1
fakie00
Registered User
 

Join Date: Nov 2009
Location: erde
Posts: 3
Abgegebene Danke: 0
Erhielt 0 Danke für 0 Beiträge
Datei umbennenen

HI,
wie kann man test.txt in textbox1.text umbenennen?
Also angenommen es steht in textbox1.text "hallo" dann will ich das test.txt in hallo.txt umbenannt wird.
es soll aber auch klappen, das die datei auch umbenannt wird wenn in textbox1.text "keinplan" steht usw.

wie geht das??
fakie00 is offline   Reply With Quote
Sponsored Links
Old 18-11-2009   #2
bst
Excel Moderator
Senior Member (Board-Inventar)
 

Join Date: Oct 2004
Location: Ilsfeld
Posts: 2.610
Abgegebene Danke: 16
Erhielt 183 Danke für 180 Beiträge
Hi,

in VBA gibt es die Name-Anweisung. Siehe VBA-Hilfe dazu.

Quote:
Syntax

Name
AlterPfadname As NeuerPfadname
cu, Bernd
bst is offline   Reply With Quote
Old 18-11-2009   #3
fakie00
Registered User
 

Join Date: Nov 2009
Location: erde
Posts: 3
Abgegebene Danke: 0
Erhielt 0 Danke für 0 Beiträge
So weit war ich auch schon, ich weiß aber nicht immer was in textbox1.text steht
also so das meine freunde bei sic zuhause was eingeben und ich es dann lesen kann und die datei soll halt so heiß wie in textbox1.text steht
fakie00 is offline   Reply With Quote
Old 18-11-2009   #4
bst
Excel Moderator
Senior Member (Board-Inventar)
 

Join Date: Oct 2004
Location: Ilsfeld
Posts: 2.610
Abgegebene Danke: 16
Erhielt 183 Danke für 180 Beiträge
Hi,

versuche das mal so ähnlich.

cu, Bernd
--
Code:
 Option Explicit

Private Sub CommandButton1_Click()
   Dim strPath As String, strOldName As String, strNewName As String
   
   strPath = "E:\test\"
   strOldName = "test.txt"
   strNewName = Trim(TextBox1.Text)
   If Len(strNewName) = 0 Then Exit Sub
   
   If LCase(Right(strNewName, 4)) <> ".txt" Then strNewName = strNewName & ".txt"
   Name strPath & strOldName As strPath & strNewName
End Sub
bst is offline   Reply With Quote
Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +2. The time now is 03:16.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 2.4.0
Template-Modifikationen durch TMS
Advertisement System V2.5 By   Branden
Copyright by NightwoLF & Jesse69