我正在使用创建文件并复制我的工作簿(xlsm)的过程,并将xls工作簿保存到创建的文件中,这样做效果很好。
当另存为被激活时,我需要删除所有宏和vba,即我需要从保存的工作簿中删除宏/ vba而不是原始工作簿。
我知道我可以将其保存为xlsx工作簿以删除所有宏和vba,但我需要将工作簿作为Macro / vba免费xls工作簿。
我有谷歌,但没有找到任何我可以使用的东西,如果我弄明白,我会继续寻找并回复。
答案 0 :(得分:-1)
我在这里找到了这个:
http://enholm.net/index.php/blog/vba-code-to-transfer-excel-2007-xlsx-books-to-2003-xls-format/
通过寻找 xlsx 文件的dirictory进行搜索,并将其更改为 xls 文件
我认为虽然可以将其更改为查找 xlsm 文件并将其更改为 xls 文件。
当我跑步时,我得到:
Run-Time error '9' Subscript out of range
Debug
Sheets("List").Cells(r, 1) = Coll_Docs(i)
is highlighted in yellow
我对vba知之甚少,无法弄明白什么不起作用。 感谢
Sub SearchAndChange()
Dim Coll_Docs As New Collection
Dim Search_path, Search_Filter, Search_Fullname As String
Dim DocName As String
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim i As Long
Search_path = ThisWorkbook.Path & "\360 Compiled Repository\May_2013"
Search_Filter = "*.xlsx"
Set Coll_Docs = Nothing
DocName = dir(Search_path & "\" & Search_Filter)
Do Until DocName = ""
Coll_Docs.Add Item:=DocName
DocName = dir
Loop
r = 1
For i = Coll_Docs.Count To 1 Step -1
Search_Fullname = Search_path & "\" & Coll_Docs(i)
Sheets("List").Cells(r, 1) = Coll_Docs(i)
Call changeFormats(Search_path, Coll_Docs(i))
r = r + 1
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
'**************************************************************
'* Changes format from excel 2007 to 2003
'***************************************************************
Sub changeFormats(ByVal dir As String, ByVal fileName As String)
Workbooks.Open fileName:=dir & fileName
ActiveWorkbook.SaveAs fileName:=dir & Replace(fileName, "xlsx", "xls"), FileFormat:=xlExcel8
ActiveWindow.Close
End Sub