How can I rewrite the following MS Word VBA macro to be compatible with Word 2007/2010/2013 -


i looking make ms word vba macro compatible word 2007,2010, , 2013 without having download ms office object libraries 12,14, , 15 on machines. types how can accomplish this? code following , seems require object library 12 & 14 or 15. doesn't work 12,14 or 15.

data1 = inputbox("what moving water damage value (enter 0.0 - 1.0).") ' validiate data  if data1 > 1 or data1 < 0 data1 = inputbox("invalid input. moving water damage value (enter 0.0 - 1.0).") end if loop until (data1 <= 1 , data1 >= 0)  data2 = inputbox("what settlement damage value (enter 0.0 - 1.0).")  if data2 > 1 or data2 < 0 data2 = inputbox("invalid input. settlement damage value (enter 0.0 - 1.0).") end if loop until (data2 <= 1 , data2 >= 0)  data3 = inputbox("what pre-exisiting damage value (enter 0.0 - 1.0).")  if data3 > 1 or data3 < 0 data3 = inputbox("invalid input. pre-exisiting damage value (enter 0.0 - 1.0).") end if loop until (data3 <= 1 , data3 >= 0)  dim integer  = activedocument.tables.count = + 1  ' create table activedocument.tables.add range:=selection.range, numrows:=5, numcolumns:=2 activedocument.tables(i).cell(1, 2).split numcolumns:=3 activedocument.tables(i).cell(1, 1).range.text = "location:" activedocument.tables(i).cell(1, 3).range.text = "quantity (measurable area):" activedocument.tables(i).cell(2, 1).range.text = "description:" activedocument.tables(i).cell(3, 1).range.text = "analysis:" activedocument.tables(i).cell(4, 1).range.text = "cause(s) of damage:" activedocument.tables(i).cell(5, 1).range.text = "recommended repairs:"  activedocument.tables(i) .borders(wdbordertop).linestyle = wdlinestylesingle .borders(wdborderleft).linestyle = wdlinestylesingle .borders(wdborderbottom).linestyle = wdlinestylesingle .borders(wdborderright).linestyle = wdlinestylesingle .borders(wdborderhorizontal).linestyle = wdlinestylesingle .borders(wdbordervertical).linestyle = wdlinestylesingle end  dim small boolean small = false dim twoseries boolean twoseries = false dim piechart boolean piechart = true  dim saleschart chart dim chartworksheet excel.worksheet   activedocument.tables(i) .borders(wdbordertop).linestyle = wdlinestylesingle .borders(wdborderleft).linestyle = wdlinestylesingle .borders(wdborderbottom).linestyle = wdlinestylesingle .borders(wdborderright).linestyle = wdlinestylesingle .borders(wdborderhorizontal).linestyle = wdlinestylesingle .borders(wdbordervertical).linestyle = wdlinestylesingle end  activedocument.tables(i).cell(4, 2).range activedocument.range(.start, .start).select end  ' add in new chart set saleschart = activedocument.inlineshapes.addchart.chart set chartworksheet = saleschart.chartdata.workbook.worksheets(1)  ' resize chart area chartworksheet.listobjects("table1").resize chartworksheet.range("a1:b4")  ' rename series 1 sales chartworksheet.range("table1[[#headers],[series 1]]").formular1c1 = "damage"  ' add data chart chartworksheet.range("a2").formular1c1 = "moving water" chartworksheet.range("a3").formular1c1 = "settlement" chartworksheet.range("a4").formular1c1 = "pre-exisiting" chartworksheet.range("b2").formular1c1 = data1 chartworksheet.range("b3").formular1c1 = data2 chartworksheet.range("b4").formular1c1 = data3   ' quit excel, since no longer need saleschart.chartdata.workbook.application.quit  ' put box around legend saleschart.legend.format.line.visible = msoctrue  ' fill background theme color accent 1 saleschart.chartarea.format.fill .visible = msotrue .solid .forecolor.objectthemecolor = wdthemecoloraccent1 end  ' add title , format saleschart.hastitle = true saleschart.charttitle .characters.font.italic = true .characters.font.size = 18 .characters.font.color = rgb(0, 0, 100) .text = "damage" end   if small ' size , move chart  saleschart.parent .left = 100 .width = 300 .height = 150 end end if  if piechart ' set chart type saleschart.charttype = xl3dpie end if  activedocument.bookmarks("\endofdoc").select selection.typeparagraph   

i've got code running in office 2010 , references version 14 libraries. appears code has been around while, , older references can removed.

to have work across different versions, you'd have change references binding late binding. way, don't need add references vb editor each new version.

can use code sample example of word macros students?

also, if need late binding (this old question) let me know.

reference binding: http://word.mvps.org/faqs/interdev/earlyvslatebinding.htm


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -