![](/img/trans.png)
[英]VBA loop through non-patterned files in folder (seek for opinions) [EDIT]
[英]VBA script to loop through files in its current folder and edit
我正在写一个vba脚本。 复制一个当前excel文件的内容(带有格式),b。 循环浏览其当前文件夹中的所有其他excel文件c。 将新复制的工作表添加到excel文件
由于某种原因,我的代码无法正常工作。 任何人都可以请帮助我是vba脚本的新手吗
Sub Macro7()
Dim wbf As Workbook
Dim myPath As String
Dim myFile As String
Dim currentFile As String
Dim mtExtension As String
myPath = Application.ActiveWorkbook.Path
currentFile = ActiveWorkbook.Name
MsgBox (myPath)
Dim objFSO As Object
Dim objFolder As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(myPath)
Count = 0
For Each objFile In objFolder.Files
If currentFile <> objFile.Name Then
Set wbt = Workbooks.Open(Filename:=myPath & "\" & objFile.Name)
MsgBox (objFile.Name)
.Sheets("Action Descriptions").Select After:=Workbooks(objFile.Name).Sheets(1)
ActiveWorkbook.Save
ActiveWindow.Close
End If
'
Next
' Loop
End Sub
在这里,您已复制一次并粘贴多次,以打开多个文件。 尝试每次在循环中进行复制,然后再粘贴另一个文件。 循环播放{打开新文件“添加”选项卡激活此工作簿复制转到其他文件粘贴保存关闭}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.