我遇到的问题是我创建的用于将* .xml - excel表格提取到网站上的图表。 它一直在工作,但过了一段时间我无法运行它。
问题在于以下一行:
Open path & "\xml_js\" & fileName For Output As 1
当文件存储在我的桌面上时,例如在我的桌面上存储宏时,宏工作正常,但问题是当我尝试从映射驱动器打开它时(sharepoint 2010)。 当我使用我的同事电脑(W7 + O2007)时,它正在工作,但不在我的电脑上(W7 + O2013)。
我收到以下错误:
运行时错误'52':
文件名或号码错误
52正是Open path & (...) As 1
行
其余代码:
Sub generateRegionsFile()
Dim fileName As String: fileName = "XXXXXX_Regions.xml"
Dim path As String: path = ThisWorkbook.path
ThisWorkbook.Sheets(1).Select
Dim rowNum As Long: rowNum = 2
Dim jsIndex As Long: jsIndex = 0
Open path & "\xml_js\" & fileName For Output As 1
Cells(15, 16).Select
Do Until ActiveCell.Value = ""
NoOfStatuses = NoOfStatuses + 1
ActiveCell.Offset(1, 0).Select
Loop
'Chart header
Print #1, "<chart caption='No. of Items' subcaption='per Region' xaxisname='Region' yaxisname='Number of Region' showsum='0' numberprefix='' palette='3' rotatenames='0' animation='1' basefont='Arial' basefontsize='12' useroundedges='' legendborderalpha='0' canvasbgalpha='0' bgcolor='#fffefe' bgalpha='50' plotgradientcolor='' showplotborder='0' showborder='0' showlegend='0'>"
Print #1, ""
Print #1, " <categories>"
Cells(15, 16).Select
For x = 1 To NoOfStatuses
Print #1, " <category label='" & ActiveCell.Value & "' />"
ActiveCell.Offset(1, 0).Select
Next
Print #1, " </categories>"
Print #1, " <dataset seriesname='Number of items'>"
Cells(15, 17).Select
For x = 1 To NoOfStatuses
Print #1, " <set value='" & ActiveCell.Value & "' />"
ActiveCell.Offset(1, 0).Select
Next
Print #1, " </dataset>"
Print #1, "</chart>"
Close #1
End Sub
答案 0 :(得分:0)
在错误之前写下这个:
debug.print path & "\xml_js\" & fileName
你会看到你想要打开的东西。可能您的path
是错误的,或者您遗失了\\
或其他内容。