Writing a Macro for Ms Word, anyone knows VBA?

Hi again..

Does any one among you know VBA?
Actually I am writing a Macro for Ms Word, and am stuck up.
If any one knows VBA please let me know..

Always there,
Mrunalini ๐Ÿ˜€

Replies

  • Kaustubh Katdare
    Kaustubh Katdare
    I'm sure we've big number of CEans who know VB. Could you post the details of macro you're trying to write and tell us where you're stuck?

    That should help us help you ๐Ÿ˜€
  • Mrunalini
    Mrunalini
    Thanks for a reply..

    I am writing a VBA application which scans the entire document.
    While scanning if it comes across any font which is not Times New Roman, it takes the user to that particular location.

    The code is as follows:

    Sub functionxyz1()
    Selection.HomeKey Unit:=wdStory
    For i = 1 To ActiveDocument.ComputeStatistics(Statistic:=wdStatisticLines)
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
    If Selection.Font.Name <> "Times New Roman" Then
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Font_Change.Show
    End If
    Next i
    End Sub


    The user form Font_Change has 2 buttons "Ok and Canel"
    If the user clicks on Ok.. it converts the font to Times New Roman, if cancel, then the font is not changed.

    The code behind Ok is:
    Private Sub Ok_Command_Click()
    With Selection.Font
    .Name = "Times New Roman"
    .Size = 10
    Unload Me
    End With
    End Sub

    and behind cancel is:

    Private Sub Cancel_Command_Click()
    Unload Me
    End Sub


    Now, the problem is that, the above code Moves down and selects the next text as well, so when I run the Macro on a document, say I Cancel to change the font on the 1st line, but I want to change the font on line 2. But according to the code both the lines are selected (as I'm using MoveDown), and so the font for both the lines are changed.
    But actually this not the thing that I need..


    Please help me, and let me know where I've gone wrong..
    Waiting for a reply and kind suggestions if any.

    Thanks
    Mrunalini ๐Ÿ˜€

You are reading an archived discussion.

Related Posts

Hi Everyone, Yesterday I met with an accident and by the help of God still alive and writing this thread.๐Ÿ˜Ž Yesterday I was walking to my house. Since It was...
If any body could tell me from where i can get help on DSP board. thier different modules and how to sart working on DSP board
Hi All, Please help me for writing macro in VBA for removing leading as well as trailing spaces of relational as well as arithmetic operators. I tried using "Trim" as...
hi i need your help on the project of mechanical .please help me and suggest some new opics to me which is economical too.
CEans! CrazyEngineers is giving away free passes to CEans who want to attend :- NVIDIA's NVISION 2008 [ August 25 - 27, San Jose, CA ] About NVISION 2008 in...