|
我想用VBA将表格另存至别的电脑上,报错提示:文件名或文件号错误;请各位大神帮我看看如何解决?
同一局域网、文件也已能共享,需要存到电脑IP:192.168.116.162----G盘下----文 “文”的文件夹里
代码如下:
n = 1
If Dir("\\192.168.116.162\g:\文\" & Year(Date), vbDirectory) <> "" Then
Else
MkDir "\\192.168.116.162\g:\文\" & Year(Date)
End If
If Dir("\\192.168.116.162\g:\文\" & Year(Date) & "\" & Month(Date) & "月", vbDirectory) <> "" Then
Else
MkDir "\\192.168.116.162\g:\文\" & Year(Date) & "\" & Month(Date) & "月"
End If
If Dir("\\192.168.116.162\g:\文\" & Year(Date) & "\" & Month(Date) & "月" & "\" & Day(Date) & "日", vbDirectory) <> "" Then
Else
MkDir "\\192.168.116.162\g:\文\" & Year(Date) & "\" & Month(Date) & "月" & "\" & Day(Date) & "日"
End If
TStr = "\\192.168.116.162\g:\文\" & Year(Date) & "\" & Month(Date) & "月" & "\" & Day(Date) & "日" & "\" & "(" & Format(Date, "YYYY-M-D") & "-" & Format(Time, "HHMM") & ")" & ActiveSheet.Cells(3, 6) & ActiveSheet.Cells(2, 6) & " 记录" & "-" & n & ".xls"
Do While Len(Dir(TStr))
n = n + 1
TStr = "\\192.168.116.162\g:\文\" & Year(Date) & "\" & Month(Date) & "月" & "\" & Day(Date) & "日" & "\" & "(" & Format(Date, "YYYY-M-D") & "-" & Format(Time, "HHMM") & ")" & ActiveSheet.Cells(3, 6) & ActiveSheet.Cells(2, 6) & " 记录" & "-" & n & ".xls"
Loop
ThisWorkbook.SaveAs Filename:="\\192.168.116.162\g:\文\" & Year(Date) & "\" & Month(Date) & "月" & "\" & Day(Date) & "日" & "\" & "(" & Format(Date, "YYYY-M-D") & "-" & Format(Time, "HHMM") & ")" & ActiveSheet.Cells(3, 6) & ActiveSheet.Cells(2, 6) & " 记录" & "-" & n & ".xls"
|
|