I'm having problem with macro which I've created to extract *.xml - excel table to chart on website. It was working all the time but after a while I'm not able to run it.
Problem is with line below:
Open path & "\xml_js\" & fileName For Output As 1
Macro is working perfectly fine when file is stored localy for example on my desktop but problem is when I'm trying to open it from mapped drive (sharepoint 2010). It is working when I'm using my colleague computer (W7 + O2007) but not on mine (W7 + O2013).
I'm getting error below:
Run-time error '52':
Bad file name or number
52 is exactly Open path & (...) As 1
line
The rest of the code:
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
Write this before the error:
debug.print path & "\xml_js\" & fileName
You would see what you are trying to open. Probably your path
is false or you are missing \\\\
or something else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.