Solved

Word Macro  that will move the cursor to the 2nd Cell in the 3rd Table in the Active Word Document

Posted on 2009-04-11
7
796 Views
Last Modified: 2012-06-21
I need help writing a Macro that will move the cursor to the 2nd Cell in the 3rd Table in the Active Word Document.
0
Comment
Question by:FaheemAhmadGul
  • 3
  • 2
  • 2
7 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 250 total points
ID: 24122128
Hello FaheemAhmadGul,

Word VBA doesn't let you move in that way, you have to step through the docuemnt.  You can howeever read / write diresctly:

Write:
    thisdocument.Tables(3).Cell(1,1).Range.Text = "Fred"
Read:
    thisdocument.Tables(3).Cell(1,1).Range.Text

Note however it is cell(row, column) rather than cell(x)

Regards,
Chris
0
 

Author Comment

by:FaheemAhmadGul
ID: 24122249
I have been able to use the code provided by you to get my cursor where I wanted it to be. This is by first writing to the Cell  I want the Cursor to go to, then taking the cursor to that cell by searching for that word.

Many thanks for your help. I am grateful.
Regards
Faheem
Private Sub btnCellThree_Click()
 

ThisDocument.Tables(3).Cell(1, 2).Range.Text = "Fred"
 

Selection.Find.ClearFormatting

    With Selection.Find

        .Text = "Fred"

        .Replacement.Text = ""

        .Forward = True

        .Wrap = wdFindContinue

     

    End With

    Selection.Find.Execute

    Selection.Delete Unit:=wdCharacter, Count:=1

  

    Selection.TypeText Text:="This has worked."

   

    

  
 

End Sub

Open in new window

0
 

Author Closing Comment

by:FaheemAhmadGul
ID: 31569168
have been able to use the code provided by you to get my cursor where I wanted it to be. This is by first writing to the Cell  I want the Cursor to go to, then taking the cursor to that cell by searching for that word.

Many thanks for your help. I am grateful.
Regards
Faheem
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 24122280
NOw that is sneaky! ... but clever.  Personally I would have set a bookmark but your way is perhaps even simpler so thank you for the advice.

I didn't define such possibilities as I was assuming the need was to type something there or read the value.  I would of course have taken it further had that been the requirement - but I am pleased you did so for yourself.

Chris
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 24122475
I should have done it in your previous question, but it isn't too difficult:
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 24122477
This the code that I meant to include with the previous comment
Sub MoveTocell()

 ActiveDocument.Tables(3).Cell(2, 2).Range.Select

End Sub

Open in new window

0
 

Author Comment

by:FaheemAhmadGul
ID: 24122684
This is brilliant !  Accomplishes what I wish to do in a much simpler way. I actually wanted to be able to take the cursor to a specific cell in a specific table in my document and run a number of other macros and commands when the cursor was there. This one line of code, very kindly provided you, solves the problem.
I am very grateful. Thank you very much.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Lately there has been a variety of news related to U.S. employment.  Stories about worker productivity, automobile and airline unions, low employment and foreign laborers have frequented the news.  Each story has good and bad attributes we might arg…
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now