Invoke VBA For Word

Hello Eveyone,
Can we Invoke VBA Code in MSWord or it is only applicable for Excel?

Jyothi M B

1 Like

Invoke VBA is valid only for Excel application scope as far as I know @jyothi_M.B. We have lot of activities to do in word for whatever you want to do.

Can you explain the requirement you have so that someone will help you with that?

1 Like

@HareeshMR I Need to execute the macros for ms word

1 Like

Then you can use Invoke Code activity to open the word and then do the required instead of macros or invoke vba @jyothi_M.B

1 Like

@HareeshMR
I have written the Macros in Invoke Code Activity Here I am getting the Errors.

I mean, you need to write the code for opening the word, then do the requirements and then close the word document. No need of word application scope now.

Coming to the issues you are getting, you need add some dependencies or the namespaces based on the error you are getting. Can you please check which needs to be add?

Option Explicit
Sub m_border()
Dim shpIn As InlineShape, shp As shape

For Each shpIn In ActiveDocument.InlineShapes
    If (shpIn.Type = wdInlineShapeLinkedPicture) Then
        Set shp = shpIn.ConvertToShape
        shp.WrapFormat.Type = wdWrapTight
    End If
Next shpIn

For Each shp In ActiveDocument.Shapes
    shp.WrapFormat.Type = wdWrapTight       
Next shp

End Sub

I am writting the above code
The screenshot is the error

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.