Vba无法识别变量文件名
问题描述:
,以便将日期放入我创建的工作簿中。我使用此代码。Vba无法识别变量文件名
Dim tarih As String
Dim dot As String
dot = "."
Dim days2 As Integer
Dim months2 As Integer
Dim years2 As Integer
days2 = Day(Date)
months2 = Month(Date)
years2 = Year(Date)
tarih = days2 & dot & months2 & dot & years2
Workbooks.Add
ActiveWorkbook.SaveAs "C:\Users\" & Environ$("USERNAME") & "\Desktop\Excel Before Code Templates (BCT)\ROL_Analysis" & tarih & ".xlsx"
Application.WindowState = xlMinimized
Dim strii As String
strii = "ROL_Analysis" & tarih & ".xlsx"
Workbooks("ROL_Analysis" & tarih & ".xlsx").Activate
我直接使用名称,之后我定义了一个字符串来放它,但它不起作用。有任何想法吗?
答
Workbooks.Add
Dim strii As String
strii = "ROL_Analysis" & tarih & ".xlsx"
ActiveWorkbook.SaveAs "C:\Users\" & Environ$("USERNAME") & "\Desktop\Excel Before Code Templates (BCT)\" & strii & ""
Application.WindowState = xlMinimized
Workbooks(strii).Activate
确定这个工程
你得到一个错误?什么线? –