Home » excel » excel – .SaveAs Method or Data Member Not found

excel – .SaveAs Method or Data Member Not found

Posted by: admin May 14, 2020 Leave a comment

Questions:

I’m trying to save an XML from Excel conversion into newDoc which is a MSXML2.DOMDocument, however whenever I run my code it highlights .SaveAs and says that the method or data member is not found. I understand that this is because newDoc is not a workbook, but how else would I go around this?

xslDoc.async = False
    doc.transformNodeToObject xslDoc, newDoc
    Dim Docname As String
    Dim fileSaveName As Variant
    Docname = "123_" & SN.Text
    fileSaveName = Application.GetSaveAsFilename(InitialFileName:=sItem * Docname, filefilter:="XML Files (*.xml),*xml")
   ' 
    newDoc.SaveAs Filename:=fileSaveName, FileFormat:=xlTextPrinter, CreateBackup:=False
How to&Answers:

You can use the save method of the DOMDocument class (note that the FileFormat and CreateBackup are not arguments for this method).