Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
826 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 1000 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
 
LVL 1

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
 
LVL 1

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
LVL 1

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Gain an elementary understanding of Blockchain technology.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
Suggested Courses

610 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