Macro to generate Xml files

Negi1984

Board Regular
Joined
May 6, 2011
Messages
199
Hi All,

I was using below code to generate .mo format files. Now I need to generate .Xml files using below code.
So I changed the .Mo extension to .xml in below code. But its not working. When I am opening that xml in internet explorer it opening as blank.

Can anybody suggest me what and where I need to change in below code :-

Code:
Sub CancellaExternalCellGSM()
Dim Riga As Integer, RncId As Integer, NodeName As String, I As Integer, Appoggio As String
CountExternalG = 0
With Sheets("External GSM Dataset 1")
    
    Riga = 13
    
    Open TxtPath & "04_Del Rel_U2G_InterGsm_ExternalGsmCell.xml" For Output As [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] 
    While .Cells(Riga, 6) <> ""
        RncNome = ""
        If Trim(UCase(.Cells(Riga, 1))) = "C" Then
            CountExternalG = CountExternalG + 1
'            Appoggio = .Cells(Riga, 6)
'            If InStr(1, Appoggio, "_") > 0 Then
'                 Appoggio = Mid(Appoggio, 1, InStr(1, Appoggio, "_") - 1)
'            End If
            If InStr(1, .Cells(Riga, 6), "_") > 0 Then
                Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , "ECHO ""RBS ID " & Mid(.Cells(Riga, 6), 1, InStr(1, .Cells(Riga, 6), "_") - 1) & """"
            Else
                Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , "ECHO ""RBS ID " & .Cells(Riga, 6) & """"
            End If
                       
            Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , " DELETE"
            Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , " ("
            If InStr(1, .Cells(Riga, 6), "_") > 0 Then
                Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , "    mo ""ManagedElement=1,RncFunction=1,ExternalGsmNetwork=1,ExternalGsmCell=" & Mid(.Cells(Riga, 6), 1, InStr(1, .Cells(Riga, 6), "_") - 1) & """"
            Else
                Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , "    mo ""ManagedElement=1,RncFunction=1,ExternalGsmNetwork=1,ExternalGsmCell=" & .Cells(Riga, 6) & """"
            End If
            Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , "    exception none"
            Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , " )"
            Print [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] , ""
         End If
        Riga = Riga + 1
    Wend
End With
Close [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1[/URL] 
    
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Xml is completely different, you'll prpbably need a new macro. Additionally, to help, we'd need to see an example of the xml you're trying to generate
 
Upvote 0
Hi Kyle,

Actually this macro was written by someone else and there are similar linked more macros in original file. I thought it was task of just changing the extension of generated file to .xml. Will share the original file by removing data. Also want to know if we can separately change the *.mo or *.txt extension file to *.xml without changing the original macro ?

Thanks in advance for your feedback.
Xml is completely different, you'll prpbably need a new macro. Additionally, to help, we'd need to see an example of the xml you're trying to generate
 
Upvote 0
If you mean the macro you posted, then no, you can't. You'll either need a new macro to write the xml or change above. Xml isn't just a different extension, it needs formatting properly. We will therefore need an example of the xml you want to create and the original data
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top