Hello everyone , is here any one to help me with visual basic macro?
here is the macro code :
VB Code:
Attribute VB_Name = "gw_twocolumn" Sub gw_twocolumn_to_xml() str_startTime = Time CRLF = Chr(13) + Chr(10) str_range = ActiveWindow.RangeSelection.Address() str_1 = "<line><term>" str_2 = "</term><defn><trns>" str_3 = "</trns></defn></line>" Rem Rem Sheets.Add Count:=1, after:=Sheets(1) Worksheets(1).Activate Set r = Range(str_range) For n = 1 To r.Rows.Count Worksheets(2).Cells(n, 1) = _ str_1 & r.Cells(n, 1) & _ str_2 & r.Cells(n, 2) & str_3 Next n Worksheets(2).Columns(1).ColumnWidth = 150 Rem Rem str_stopTime = Time double_elapsedTime = (str_stopTime - str_startTime) * 24 * 60 * 60 MsgBox "Range: " & str_range & CRLF & _ "Elapsed time: " & double_elapsedTime & _ " sec." End Sub
When you open excel file , name one cloumn = term and the second one = defn ,when i run the macro the generated code in excel sheet look like this
---------------------------- XML Code Start----------------------------------
<line><term>rule</term><defn><trns>Control</trns></defn></line>
<line><term>manage</term><defn><trns>Supervise</trns></defn></line>
<line><term>management</term><defn><trns>Supervision</trns></defn></line>
-----------------------------Xml Code end------------------------------------
this macro is for making a dictionary so if you look at this code closely and look at the grammer point you may understand it well and i want the code to generate somthing like this
-------------------------------Xml Code start -------------------------------
<line><term t1="C" t2="CO" id="12">Control</term><defn><abbr lang="noun"></abbr>rule</defn></line>
<line><term t1="S" t2="SU" id="3">Supervise</term><defn><abbr lang="verb"></abbr>manage</defn></line>
<line><term t1="S" t2="SU" id="7">Supervision</term><defn>management</defn></line>
-------------------------------Xml Code end -------------------------------
Or like this
--------------------------------Xml Code Start ----------------------------
<line><term>Control</term><defn><abbr lang="noun"></abbr>rule</defn></line>
<line><term>Supervise</term><defn><abbr lang="verb"></abbr>manage</defn></line>
<line><term>Supervision</term><defn>management</defn></line>
----------------------------------Xml Code End -----------------------------
i put the important point in green color
the important thing is the grammer part i mean to show wether this term is ( verb or noun or adjective etc... )
I need the macro that what ever i write in excel cloumn it bring that in a code like this
<abbr lang="( the words in cloumn should come here)"></abbr>
I will be looking forward to your replies as soon as possible .
Best regards.




Reply With Quote