We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


how can i get vbscript to save changes to a(local) xml file? xmldoc.save {path} method gives me 'Access Denied' errors

Medium Priority
Last Modified: 2013-12-17
I have written a small IE/vbscript app in Vis.Interdev (VS6), basically a rough database using XML files. All is happy in developer world but when I put the app into the real world it won't save any work.
I can load and manipulate the XML data, but how can i get vbscript to save changes to a(local) xml file?
The xmldoc.save {path} method just gives me 'Access Denied' errors.
Watch Question

Top Expert 2007

Make sure the IWAM_YOUR_MACHINE_NAME_HERE user has r/w permission on the folder.
b0lsc0ttIT Manager


When you say "real world" what does that mean?  Is this a public website and page?  Is the protocol http or https?  What does IE show for the zone (i.e. trusted, Internet, etc)?

If an Internet page and it is in that zone for IE then what happens if you have the user add that domain to the Trusted list?  Security settings still may not allow it but that is what I would first try.

Is this app an  ActiveX object or what exactly?

Let me know if you have any questions or need more information.

Database Developer
I  couldn't get the save method to work in the end but did find a way around the issue. It's dirty and left me feeling unclean, but it worked!
I simply copied the XML to a file, deleting and then overwriting the source document!

Function SaveDoc(pDocument)
' This is a dirty workaround the xmldoc.save function which typically won't work
'for whatever reason

      Dim oSys
      Dim oFile
      dim tURL
      dim tXML
      dim msg
      dim oURL
      dim oPos
      On Error Resume Next
      Set oSys = CreateObject("scripting.filesystemobject")
      If oSys Is Nothing Then
            MsgBox "Failed to create the filesystem object"
            Exit Function
      End If
      select case pDocument
            case DOC_SCORES
                  oURL = gScores.url
                  tXML = gScores.xml
            case DOC_SHOOTERS
                  oURL = gShooters.url
                  tXML = gShooters.xml
            case else
      end select

      'Look for the drive letter indicator :/
      oPos = InStrRev(oURL, ":/")
      tURL = right(oURL,len(oURL) - oPos + 2)
      tURL = Replace(tURL,"/","\")

      if oSys.FileExists(tURL) then
            call oSys.DeleteFile(tURL,true)
      end if
      Set oFile = oSys.CreateTextFile(tURL, True)

      if oFile is nothing then
            msgbox "Save XML document Error: 'oFile is Nothing'"
      end if
      oFile.Write (tXML)

      If Not Err.Number = 0 Then
      MsgBox Err.Description
      On Error GoTo 0
      End If

      Set oFile = Nothing
      Set oSys = Nothing

End Function

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.