Remove Word Textbox, Keep Information

kkazinski

New Member
Joined
Jun 23, 2015
Messages
7
I have a large number of RTF documents that I am opening using Access. I would like to reformat the document and then copy them into a control.

I am able to open the documents, and go though all the paragraphs in the document (using the paragraphs object).


I found that my macro's are missing any text boxes. I thought I could look in the shapes collection that are in the paragraph but it does not seem like the textboxes are not part of a paragraph.

My solution would be to remove all the information in the text box and place it into the document at the anchor point. I do not see a easy way to remove the text box via VBA.


Has anyone done this already?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Have you tried accessing the textboxes via the Shapes collection of the document?
 
Upvote 0
The issue is not looping through the shapes collection. After some experimentation I was able to solve the problem.

I have a function where I pass the objWordDoc as a word.document

Dim objShape As word.Shape
Dim Count As Long

If (objWordDoc.Shapes.Count = 0) Then

GoTo ExitFunction
End If
Count = 1
Do
Call Application.SysCmd(acSysCmdSetStatus, "UpdateWordDocument_UpdateShapes Working with shape " & Count & " of " & objWordDoc.Shapes.Count)
Set objShape = objWordDoc.Shapes(Count)
Debug.Print "Page "; objShape.Anchor.Information(wdActiveEndAdjustedPageNumber), objShape.Type
objShape.Select
DoEvents
If (objShape.Type = msoLine) Then
objShape.Delete

ElseIf (objShape.Type = msoTextBox) Then
objShape.Visible = msoTrue
objShape.TextFrame.TextRange.Select
DoEvents
objShape.ConvertToFrame.Delete
Else
Count = Count + 1
End If
Loop Until (Count > objWordDoc.Shapes.Count)
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top