Ciao a tutti.
Ho scaricato un esempio Microsoft per VBA da utilizzare per aprire file XML del Project (in coda l'esempio che richiede scrrun.dll come riferimento) e ho eseguito i seguenti passi:
- Creo un nuovo progetto in Project aggiungendo 1 task e 1 risorsa
- Salvo il file nel formato XML
- Chiudo il file
- Alt+F11 e eseguo la procedura VBA
- ERRORE di run-time '1101' - Errore definito dall'applicazione o dall'oggetto
Ho provato anche con un file nuovo e creandolo vuoto senza inserire task o risorse o altro.
Lo stesso codice non funziona su PC diversi e con SO diversi!
Public Sub ApriXML()
' Requires reference to the Microsoft Scripting Runtime library (scrrun.dll).
Dim txtStream As TextStream
Dim fileName As String
Dim xmlContents As String
Dim fsObject As FileSystemObject
fileName = "C:\testxml\vuoto.xml"
Set fsObject = CreateObject("Scripting.FileSystemObject")
If Not fsObject.FileExists(fileName) Then
MsgBox "The file does not exist: " & vbCrLf & fileName
Else
' Open a text stream.
Set txtStream = fsObject.OpenTextFile(fileName:=fileName, IOMode:=ForReading)
xmlContents = txtStream.ReadAll
Application.OpenXML (xmlContents)
txtStream.Close
End If
End Sub