『壹』 VB給文件重命名
使用 Name 語句來更改文件的名稱。示例中假設所有使用到的目錄或文件夾都已存在。
Dim OldName, NewName
OldName = "OLDFILE": NewName = "NEWFILE" '激攔 定義文件名。
Name OldName As NewName ' 更改文件名。
OldName = "
C
:\MYDIR\OLDFILE"信鉛早: NewName = "C:\YOURDIR\NEWFILE"
Name OldName As NewName ' 更改文件名,並移動文件。滑雀
其它:
使用shell語句來調用dos命令rename。
『貳』 在VB中文件改名的兩種方法
第一種(推薦余簡)
Name "原文件名" As "新文件名"
第二種
FileCopy "原文件名"豎模褲, "新文件名碼山"
Kill "原文件名"
『叄』 怎樣利用VB在EXCEL按保存或關閉時更改文件名稱
給你簡單示例:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim xl As New Excel.Application Dim xlBook As Workbook
Set xl = GetObject(, "Excel.Application")
Set xlBook = xl.ActiveWorkbook
FN1 = xlBook.Name & CStr(Year(Date))
ActiveWorkbook.SaveCopyAs "D:/" & FN1 & ".xls"
End Sub
有兩個問題你自己很容易解決了
一是截取原來文件的文件名,即從「客戶信息記錄2013-4-1」這名字中取出沖知前一部分
二是注意日期伍鉛格式,因為散橘消可能你系統的日期格式是2013/4/1,斜杠/文件名中不可用,你得檢測並轉換
『肆』 vb 文件改名
VB改名可以用name方法
Name oldpathname As newpathname
Name 語句的語法具有以下幾個部分:
oldpathname 必要參數。字元串表達式,指定已存在的文件名和位置,可以包含目錄或文件夾、以及驅動器。
newpathname 必要參數。字元串表達式,指含鍵告定新的文件名和位置,可以包含目錄或文件夾、以及驅動器。而由 newpathname 所指定的文件名不能存在。
Name 語談明句重新命名文件並將其移動到一個不同的目錄或文件夾中。如有必要,Name 可跨驅動器移動文件。 但當 newpathname 和 oldpathname 都在相同的驅動器中時,只能重新命名已經存在的目錄或文件夾。 Name 不能創建新文件、目錄或文件夾。
在一個已打開的文件上使用 Name,將會產生錯誤。必須在改變亮畢名稱之前,先關閉打開的文件。Name 參數不能包括多字元 (*) 和單字元 (?) 的統配符。
經查閱MSDN里,VB里沒有moveto方法改名,其他語言有~~下面是MoveTo 方法
MoveTo Method (Folder Object)
The MoveTo method relocates the Folder object to another folder hierarchy location.
Syntax
Set objMovedFolder = objFolder.MoveTo(folderID [, storeID ] )
objMovedFolder
On successful return, contains the moved Folder object.
objFolder
Required. This Folder object.
folderID
Required. String. The unique identifier of the new parent Folder object, that is, the Folder object under which this folder is to appear as a subfolder.
storeID
Optional. String. The unique identifier of the InfoStore object in which this folder is to appear, if different from its current InfoStore.
Remarks
All subfolders of this folder, together with all Message objects contained within this folder and its subfolders, are moved along with the folder itself.
The move operation takes effect immediately. This Folder object is no longer accessible at its former location after the MoveTo method returns.
『伍』 請問,vb中保存之後的文件不能再修改嗎
能修改,但要看看文件屬性是否只讀,如果只讀請修改文件屬性取消只讀屬性,然後可以修改。
『陸』 用vb怎樣這樣修改文件名
Private Sub command1_click()
Dim d As String
d = Dir("c:\abc\*.txt")
Do Until d = ""
Name "c:\abc\" & d As "c:\abc\" & Text1.Text & d
d = Dir
Loop
End Sub
以上代碼是把"c:\abc"目錄的所有txt的文沖旦件名前面插入text1的內容。如果只想給最新創建的文件添桐判空加,那麼可以在局瞎循環中用FileDateTime("c:\abc\" & d)檢測文件的時間,找出最新的那個即可。
『柒』 VB如何批量更改文件名
Name 語句
重新命名一個文寬罩件、目錄、或文件夾。
語法
Name oldpathname As newpathname
oldpathname --- 原文件名
newpathname --- 新文件名
例如:
Name "閭撳皬騫蟲橘伍椂浠e叏25絝_doc" As "閭撳皬騫慎伍鬧蟲椂浠e叏25絝.doc"
『捌』 VB.NET如何更改保存程序的文件夾名
很簡單陪搭的幾部操攜亂轎作
打開VS選中程序 解決方案"學生信息管理系統"
選中後 選擇VS菜單欄文件 "學生信息管理系統 "另存為
然後選擇路徑 把解決方案"學生信息管理系統" 保存到 學生信息管理系統辯肆 文件夾目錄下
這樣就可以了
『玖』 如何用vb修改文件名
二次補充:肯定沒問題了,把其他功能都去掉了,只剩下改名和刪除,如果想吧刪除去掉,就去注釋的那一句。
============敏洞薯
建一個Command1,如果需要,建立Command2。
代碼如下。
========橋者====
Dim t As Integer, s As String
Private Sub Command1_Click()
Name "c:\abc\temp_" & t & ".txt" As "c:\abc\temp.txt"
Kill "c:\abc\temp.txt" '不刪除的話去掉這一句
t = t + 1
If t = 151 Then End '比方說你想進行到文件150,顫蘆就要寫上151
End Sub
Private Sub Form_Load()
t = 121
End Sub
『拾』 VB如何更改文件的文件名,並且進行保存
使用NAME函數就行遲可以了,具體示例如下: 希望對你有所幫助. Private Sub Command1_Click() Dim src As String, des As String src = "d:\1.txt" '需要被修改的文件路徑 des = "d:\abc.txt" '修改後胡鋒的文件名褲帶晌 Name src As des End Sub
希望採納