Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Word Macro

Word Macro

Scheduled Pinned Locked Moved Visual Basic
c++dotnethelp
6 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    laphijia
    wrote on last edited by
    #1

    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'."

    R 1 Reply Last reply
    0
    • L laphijia

      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'."

      R Offline
      R Offline
      Rama Krishna Vavilala
      wrote on last edited by
      #2

      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.

      L 1 Reply Last reply
      0
      • R Rama Krishna Vavilala

        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.

        L Offline
        L Offline
        laphijia
        wrote on last edited by
        #3

        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'."

        L 1 Reply Last reply
        0
        • L laphijia

          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'."

          L Offline
          L Offline
          laphijia
          wrote on last edited by
          #4

          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'."

          R 1 Reply Last reply
          0
          • L laphijia

            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'."

            R Offline
            R Offline
            Rama Krishna Vavilala
            wrote on last edited by
            #5

            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

            L 1 Reply Last reply
            0
            • R Rama Krishna Vavilala

              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

              L Offline
              L Offline
              laphijia
              wrote on last edited by
              #6

              Rama Krishna wrote: Dim Selection as Word.Selection Dim WordApplication as New Word.Application It looks like "TYPE WORD NOT DEFINED" ???? "Nelle cose del mondo non e' il sapere ma il volere che puo'."

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups