Word 2007 Script random font generator -



Word 2007 Script random font generator -

would 1 know or able help me work word 2007. code snippet supposed set styles randomly.

//create instance of word application set objword = createobject("word.application") objword.visible = true //open existing word document, create sure file exist in path- otherwise programme fails. set objdoc = objword.documents.open("c:\scripts\test.doc") //create instance of random object set objrandom = createobject("system.random") intlow = 1 inthigh = 5 //get text of word document set objrange = objdoc.range() //get charcters of text set colcharacters = objrange.characters //set different styles randomly each strcharacter in colcharacters intrandom = objrandom.next_2(intlow,inthigh) select case intrandom case 1 strcharacter.font.name = "arial" case 2 strcharacter.font.name = "times new roman" case 3 strcharacter.font.name = "courier new" case 4 strcharacter.font.name = "forte" end select

next

you should add together programme next references:

microsoft.office.interop.word

microsoft office object library

you can right ckick on project -> add together reference, gac tab select first reference mentioned above, com tab select sec one.

ms-word

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -