Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-10-2015, 07:09 AM
alexolcz alexolcz is offline Row Number of Selected Cell in Table Windows 7 64bit Row Number of Selected Cell in Table Office 2010 64bit
Novice
Row Number of Selected Cell in Table
 
Join Date: Dec 2015
Posts: 1
alexolcz is on a distinguished road
Default Row Number of Selected Cell in Table

Hi

I am trying to write a VBA program to return the row number of the current selection. This would allow me to copy and paste the entire row which is found searching for a key word.

The code I have written so far seems to return the cell that the cursor was in before the code is run, and not the cell selected using Find.

Many thanks in advanced for any help with this,
Alex

Sub RowNumber()

Dim wApp As Word.Application
Dim wDoc As Word.Document
Dim i As Integer

'OPEN WORD IF NOT OPEN
Dim wObj As Word.Application
On Error Resume Next

' Get existing instance of Word if it exists.
Set wApp = GetObject(, "Word.Application")

If Err <> 0 Then
' If GetObject fails, then use CreateObject instead.
Set wApp = CreateObject("Word.Application")
End If

wApp.Visible = True

Set wDoc = wApp.Documents.Open("C:\Users\alex.olczak\Document s\Proposal Automation\ERS Proposal\ERS Proposal Template Edit\PeopleParagraphMacro\TableTest.docx")


'wDoc.Application.Selection.Find.ClearFormatting
wDoc.Application.Selection.Find.Replacement.ClearF ormatting
wDoc.Application.Selection.Find.Replacement.Highli ght = True
With wDoc.Application.Selection.Find


.Text = "H"
.Replacement.Text = "H"
.Forward = Flase
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With



wDoc.Application.Selection.Find.Execute Replace:=wdReplaceAll
wDoc.Application.Selection.Find.Execute
wDoc.Application.Options.DefaultHighlightColorInde x = wdYellow


a = wDoc.Application.Selection.Range.Information(wdEnd OfRangeRowNumber)
a = wDoc.Application.Selection.Information(wdEndOfRang eRowNumber)
'wDoc.Application.Selection.GoTo

MsgBox a

End Sub
Reply With Quote
 

Tags
find, table, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data validation,force cell to be filed with number if respective cell is not empty nicholes Excel Programming 0 08-01-2015 09:08 AM
Row Number of Selected Cell in Table Entering a number in a cell causes it to fill with the color of a nearby cell Bill Martz Excel 1 04-23-2015 07:57 PM
Setting a particular table cell background color when an option button is selected in Word 2007 a888 Word VBA 11 03-25-2015 05:33 AM
Pivot Table Question- Can the table display in the order the boxes were checked/selected? blackjack Excel 0 09-13-2014 08:57 PM
Row Number of Selected Cell in Table Heading row disappears from table styles when pasted table is selected andrewballem Word Tables 2 11-12-2013 05:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:24 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft