Hello, I have a macro that copies all the textboxes from excel into a word file.
After that, I would like to change the style of the textboxes internal text in word to "no spacing".
This is the code I am using. If I run it from word it works, but from excel it doesn't.
Any idea why?
After that, I would like to change the style of the textboxes internal text in word to "no spacing".
This is the code I am using. If I run it from word it works, but from excel it doesn't.
Any idea why?
VBA Code:
Sub SetTextBoxStyle()
Dim objTextBox As Shape
Dim objDoc As Document
Set objDoc = WordApp.ActiveDocument
For Each objTextBox In objDoc.Shapes
If objTextBox.TextFrame.HasText Then
objTextBox.TextFrame.TextRange.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
objTextBox.TextFrame.TextRange.ParagraphFormat.SpaceAfter = 0
End If
Next objTextBox
End Sub