Privacy Policy Cookie Policy Terms and Conditions Wikipedia:Helferlein/VBA-Macro for EXCEL tableconversion - Wikipedia

Wikipedia:Helferlein/VBA-Macro for EXCEL tableconversion

aus Wikipedia, der freien Enzyklopädie

Inhaltsverzeichnis

[Bearbeiten] Description: VBA-Macro for EXCEL tableconversion

This is version V1x of EXCEL-VBA-Macro format_as_wikitable. This Macro converts any selected range of cells into a wiki-text, that are copied via the clipboard into the wiki-editor.

[Bearbeiten] Functional reference

  • Converts an arbitrary selected cellrange into wiki-tableformat with all essential formatting information
    • fontsize, -color, -style (italic, bold, underlined)
    • background color of the cell
    • textaligment in the cells (horizontal und vertical)
    • columnwidth and lineheight
  • further on the wikioutput is volumeoptimized, that means the cellformatting code is only repeated if necessary, e.g. when another formatting option has been active an the linecell before the actual cell
  • because the frameformatting concepts of EXCEL and Wiki-table are not compatible, the frame-formatting is not converted - sorry for that.

Comments and possible errorreports should be posted under discussion.

[Bearbeiten] VBA-Source

Please copy the VBA-Source from here

[Bearbeiten] Tips for usage

[Bearbeiten] Optimize your formatting in EXCEL to get better results

Some problems and limitations in representation are listed below. An overview about representation power of this tool you get here.

[Bearbeiten] Limits in rendering

This macro aims to convert a EXCEL-table as near to wikicode as possible. Ideally the table is rendered identically in both table-representation-clients. Differences in the rendering concepts of EXCEL and wiki-table limit this goal in certain areas:

  • Frameformating: In EXCEL each cell cann have its individuel frame information on all four sides. This is not possble in wiki-table, where the framing is defined on a tablewide standard formatting.

[Bearbeiten] Avoid formats in EXCEL that lead to unwanted results

A EXCEL-table that is parsed with VBA-code returns the cellcontent under certain circumstances programmatically not the same, as it is visually rendered.

The following known problems can be avoided by used explicit diffrent EXCEL-Formatting options:

  • Locale Non-US Dateformats are not correctly exported by EXCEL-Macro interface of microsoft. There is no known solution to this.
  • Numberformat Standard should be avoided. Content of such cells is not exported correctly by EXCEL-Macro interface of microsoft; e.g. the number "1000" will be exported as "(1000)".

[Bearbeiten] Avoid Renderingconflict due to differences in default formatting rules between EXCEL and wiki-table

There are some differences in default formatting rules between EXCEL and wiki-table, which will lead to implicit Changes in the cellrendering. These conflicts can be avoided by using explicit formatting rules in EXCEL. You will have to override the EXCEL-defaults by explicitly using attributing formats. You will see no difference in EXCEL, the difference will only emanate when rendering the converted wiki-output. This mainly concerns

  • Horizontal alignment
  • Vertical alignment

[Bearbeiten] How to use this VBA-Macro

In short: Select the macrotext above, insert it into a EXCEL/VBA-Modul and start. If more details are needed, follow the instructions below, the commands may vary slightly depending on your excel version:

  1. With Excel use: File > Open and open the .xls file of the spreadsheet table you want to convert.
  2. Open the macro-editor (menu: Special/Macro/Visual-Basic-editor) or 'Alt-F11'
  3. In the left window you should see the open VBA-Projects in the Project-Explorer. If not open that subwindow with CTR-R or View>ProjectExplorer.
  4. There you right-click on 'VBA-Project' with the cursor placed at the name of your actual document
  5. In the context menu use Insert/Module
  6. Somewhere eg. in the right you will get a popup window with a empty white area, with two dropdownboxes on the top (General and Declarations)
  7. Select the entire vba-Code above and insert it into that empty white area. Later when saving this you will actually create a new module.
  8. Go back to your worksheet, do the final formatting of your table, then select the cellrange you want to convert into a wiki-table.
  9. Execute the macro format_as_wikitable
  10. A new worksheet with name "Wikioutput" is created, where the wikitext is written
  11. Copy this text via clipboard into the wiki-editor
  12. Use the preview function of the wiki-editor
  13. When you are satisfied with the results save your wiki-work
There might be some slight differences in your default window-layouts in VBA-Editor. Please also keep in mind that I am working on a german EXCEL-Installation. Although the menu pathnames etc. are somewhat blindly translated into english it is possibile to improve on the english installation.

Comments or any problems may be posted to Discussionpage, which is on my watchlist. --ollio 13:21, 10. Apr 2006 (CEST)

[Bearbeiten] Using the macro as EXCEL-Add-in

You can also store an EXCEL-file with the macro-code as an XLA-addin-file. Thereafter you can use the macro as a addin-command, so you don't have to copy it into each file where you want convert a table.

Howto install a macro as EXCEL-Add-in:
First you install the macro in file, with an empty worksheet. You can then generate a XLA-Addin File:

  • Save this file as XLA-Addin: File > SAVE as. In the SaveAs-Dialog you have to change the filetype to XLA.
  • Give the XLA-File a meaingfull name (e.g.: Writewikitable.xla). The path of the file is automatically changed to C:\Own documents\myUsername\application data\Microsoft\AddIns. Save the file now.
  • Close EXCEL and reopen it
  • Under Extras > Addins you will now see your newly created XLA-Addin. You must activate it by its checkbox
  • The macro Format_as_wikitable is now available - even it is not visible under Extras > Macro > Execute.

Of course it's now troublesome to tiping blindly the macroname everytime you want to use it. To help yourself you can create a userdefined menuentry and assign this macro to it. --ollio 20:57, 16. Okt. 2006 (CEST)

[Bearbeiten] Samples of created output: Link to the gallerie

69.159.107.152 has added an sample of created output. It has been transferred to the gallerie. Please trim your samples not be too big. --ollio 09:36, 5. Nov. 2006 (CET)

THIS WEB:

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - be - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - closed_zh_tw - co - cr - cs - csb - cu - cv - cy - da - de - diq - dv - dz - ee - el - eml - en - eo - es - et - eu - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gd - gl - glk - gn - got - gu - gv - ha - haw - he - hi - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mg - mh - mi - mk - ml - mn - mo - mr - ms - mt - mus - my - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - rm - rmy - rn - ro - roa_rup - roa_tara - ru - ru_sib - rw - sa - sc - scn - sco - sd - se - searchcom - sg - sh - si - simple - sk - sl - sm - sn - so - sq - sr - ss - st - su - sv - sw - ta - te - test - tet - tg - th - ti - tk - tl - tlh - tn - to - tokipona - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu

Static Wikipedia 2008 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2007:

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - be - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - closed_zh_tw - co - cr - cs - csb - cu - cv - cy - da - de - diq - dv - dz - ee - el - eml - en - eo - es - et - eu - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gd - gl - glk - gn - got - gu - gv - ha - haw - he - hi - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mg - mh - mi - mk - ml - mn - mo - mr - ms - mt - mus - my - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - rm - rmy - rn - ro - roa_rup - roa_tara - ru - ru_sib - rw - sa - sc - scn - sco - sd - se - searchcom - sg - sh - si - simple - sk - sl - sm - sn - so - sq - sr - ss - st - su - sv - sw - ta - te - test - tet - tg - th - ti - tk - tl - tlh - tn - to - tokipona - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu

Static Wikipedia 2006:

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - be - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - closed_zh_tw - co - cr - cs - csb - cu - cv - cy - da - de - diq - dv - dz - ee - el - eml - en - eo - es - et - eu - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gd - gl - glk - gn - got - gu - gv - ha - haw - he - hi - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mg - mh - mi - mk - ml - mn - mo - mr - ms - mt - mus - my - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - rm - rmy - rn - ro - roa_rup - roa_tara - ru - ru_sib - rw - sa - sc - scn - sco - sd - se - searchcom - sg - sh - si - simple - sk - sl - sm - sn - so - sq - sr - ss - st - su - sv - sw - ta - te - test - tet - tg - th - ti - tk - tl - tlh - tn - to - tokipona - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu