Word Macro
-
My Word macro has grown HUGE, so I want to convert it to some C or C++ console application, or whathever, so that It can run i Background. Is possible to make an exe out of a Macro, convert the VBA and make and compile it, etc. This macro simply makes some standard modifies to a TEXT file. The problem is that the Macro language i think VBA, has some advanced funcions to move the cursor in the text. Like Selection. .MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend .HomeKey .TypeText Text:=hello .TypeParagraph .TypeBackspace .Delete Unit:=wdCharacter, Count:=3 "Nelle cose del mondo non e' il sapere ma il volere che puo'."
-
My Word macro has grown HUGE, so I want to convert it to some C or C++ console application, or whathever, so that It can run i Background. Is possible to make an exe out of a Macro, convert the VBA and make and compile it, etc. This macro simply makes some standard modifies to a TEXT file. The problem is that the Macro language i think VBA, has some advanced funcions to move the cursor in the text. Like Selection. .MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend .HomeKey .TypeText Text:=hello .TypeParagraph .TypeBackspace .Delete Unit:=wdCharacter, Count:=3 "Nelle cose del mondo non e' il sapere ma il volere che puo'."
Ofcourse, you can cut and paste the code in a VB module and compilet it. Of course you may need to add the appropriate reference and also make some small corrections.
-
Ofcourse, you can cut and paste the code in a VB module and compilet it. Of course you may need to add the appropriate reference and also make some small corrections.
I dont know much about VB. My code is something like: Selection.MoveUp Unit:=wdLine, Count:=1 Selection.HomeKey Unit:=wdLine Selection.MoveRight Unit:=wdCharacter, Count:=87 Selection.Delete Unit:=wdCharacter, Count:=6 Selection.PasteAndFormat (wdPasteDefault) Selection.TypeBackspace Selection.TypeBackspace Selection.TypeBackspace Selection.MoveLeft Unit:=wdWord, Count:=1 Selection.TypeBackspace Selection.MoveRight Unit:=wdWord, Count:=8 Selection.Delete Unit:=wdCharacter, Count:=1 Selection.Delete Unit:=wdCharacter, Count:=1 Selection.PasteAndFormat (wdPasteDefault) Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Delete Unit:=wdCharacter, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=2 Selection.MoveLeft Unit:=wdWord, Count:=2, Extend:=wdExtend Selection.TypeText Text:="=" And I copied it into the sub main of module one in a new Visual Basic Console application. But everithing don't work. Selection wdCharacter,wdExtend, wdLine, is undeclared, etc etc etc HELP PLEASE! "Nelle cose del mondo non e' il sapere ma il volere che puo'."
-
I dont know much about VB. My code is something like: Selection.MoveUp Unit:=wdLine, Count:=1 Selection.HomeKey Unit:=wdLine Selection.MoveRight Unit:=wdCharacter, Count:=87 Selection.Delete Unit:=wdCharacter, Count:=6 Selection.PasteAndFormat (wdPasteDefault) Selection.TypeBackspace Selection.TypeBackspace Selection.TypeBackspace Selection.MoveLeft Unit:=wdWord, Count:=1 Selection.TypeBackspace Selection.MoveRight Unit:=wdWord, Count:=8 Selection.Delete Unit:=wdCharacter, Count:=1 Selection.Delete Unit:=wdCharacter, Count:=1 Selection.PasteAndFormat (wdPasteDefault) Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Delete Unit:=wdCharacter, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=2 Selection.MoveLeft Unit:=wdWord, Count:=2, Extend:=wdExtend Selection.TypeText Text:="=" And I copied it into the sub main of module one in a new Visual Basic Console application. But everithing don't work. Selection wdCharacter,wdExtend, wdLine, is undeclared, etc etc etc HELP PLEASE! "Nelle cose del mondo non e' il sapere ma il volere che puo'."
-
Selection seems to be a Word Library Object. Should I import the Word Library to my project for make my code working again? "Nelle cose del mondo non e' il sapere ma il volere che puo'."
Define Global objects like this Dim Selection as Word.Selection Dim WordApplication as New Word.Application Sub Form_Load set Selection = WordApplication.Selection End Sub
-
Define Global objects like this Dim Selection as Word.Selection Dim WordApplication as New Word.Application Sub Form_Load set Selection = WordApplication.Selection End Sub