![]() |
#1
|
|||
|
|||
![]() I am using this type of code .I have to delete entire line which contain image of height and width 24.If I skip "Selection.Rows.Delete" this line then it is deleting all shapes in 2 attempts but give run time error. I am new to VBA . So please suggest me how to correct this code Sub our() Dim iShapeCount As Integer Dim iILShapeCount As Integer Dim DocThis As Document Dim J As Integer Dim K As Integer Dim sTemp1 As Integer Dim sTemp2 As Integer Set DocThis = ActiveDocument iShapeCount = DocThis.Shapes.Count For J = 1 To iShapeCount sTemp1 = DocThis.Shapes(J).Height sTemp2 = DocThis.Shapes(J).Width If sTemp1 = 24 And sTemp2 = 24 Then DocThis.Shapes(J).Delete Selection.Rows.Delete End If Next J iILShapeCount = DocThis.InlineShapes.Count For J = 1 To iILShapeCount sTemp1 = DocThis.InlineShapes(J).Height sTemp2 = DocThis.InlineShapes(J).Width If sTemp1 = 24 And sTemp2 = 24 Then DocThis.InlineShapes(J).Delete Selection.Rows.Delete End If Next J End Sub |
#2
|
||||
|
||||
![]()
Can you post a sample of the document and indicate what exactly you are trying to do.
Your post mentions 'lines' and code refers to 'rows' without any indication of what they relate to. Removing a shape should be straightforward once we know what exactly you want to remove and what else is in the document that you don't. A sample document will explain far more than your description. Go Advanced to attach a document to the forum.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
I have to delete entire line containing this computer and comment symbol.
|
#4
|
||||
|
||||
![]()
There is no line in the document that contains 'this computer' and comment symbol. Can I assume you mean the line that contains 'Change Notification: Initial Screen' ? In which case
Code:
Sub DeleteRow() Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find Do While .Execute("Change Notification: Initial Screen") oRng.Rows(1).Delete Exit Do Loop End With End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
![]()
I have to delete this computer shape , comment shape,Change Notification: Initial Screen,In the next steps, the tasks will be set to Complete status.
I need a code that will delete the starting symbol as well as line following it. In my document there are number of lines that have computer shape and comment shape in starting so i cannot delete it on basis of matching text. Please help me. |
#6
|
||||
|
||||
![]()
Your attached document has four small tables, none of which matches your description and now you tell us that there are more lines (presumaby table rows) that you need to process. As before we need to see the document to see what it is we are dealing with, not just an unrepresentative bit of it.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#7
|
|||
|
|||
![]()
This picture clearly shows what i want to do.
I need code to delete all lines that start with this computer symbol and comment symbol. Last edited by anand; 06-18-2015 at 11:25 PM. |
#8
|
||||
|
||||
![]()
It gets us a little closer, but the document is bizarrely formatted using assorted tables, with different numbers of columns in the rows. Even on a basic level such tables are difficult to handle.
However, as you originally identified, the only thing you can really hang the code on here is the size of the graphics. If we can assume all the graphics to be removed have the same sizes then the following macro may work, but without the document to test against the results may be unpredictable because of the table format: Code:
Sub DeleteImages() Dim oShape As InlineShape Dim oRng As Range For Each oShape In ActiveDocument.InlineShapes If oShape.Height = 24 And oShape.Width = 24 Then Set oRng = oShape.Range oRng.Rows(1).Delete End If Next oShape End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
tahakirmani | Word | 2 | 11-28-2013 05:33 PM |
Adapting a line shape | NikkiB | Word | 4 | 03-18-2013 08:45 AM |
Find/Delete inline Page #'s | alderfall | Word | 6 | 11-06-2012 11:51 AM |
How do i get my text in columns straight and inline in word 2007? | terrasaw | Word | 0 | 09-03-2008 06:00 AM |
Delete excel files by code in Access | Barry Richardson | Office | 0 | 06-13-2005 06:26 AM |