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
806 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 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Suggested Solutions

With the internet and the ease of information transference, many professional jobs can be done anywhere today.  Why should it make a difference whether an x-ray is read in India or the United States as long as the radiologist is qualified?   Outso…
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 …
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…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

726 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