Sub SelectTableRunAcronymAlyse()
Dim sourceTable As Table
Dim newDoc As Document
Dim macroName As String
' Ensure selection is inside a table
If Not Selection.Information(wdWithInTable) Then
MsgBox "Please place the cursor inside a table before running this macro.", vbExclamation
Exit Sub
End If
' Reference the selected table
Set sourceTable = Selection.Tables(1)
' Copy the table
sourceTable.Range.Copy
' Create a new document
Set newDoc = Documents.Add
' Paste the table into the new document
newDoc.Range.Paste
' Ensure the new document is active
newDoc.Activate
' Run your existing macro in the new document
Application.Run "NewMacros.Module1.AcronymAlyse"
MsgBox "Table copied and macro executed successfully.", vbInformation
End Sub
Dim sourceTable As Table
Dim newDoc As Document
Dim macroName As String
' Ensure selection is inside a table
If Not Selection.Information(wdWithInTable) Then
MsgBox "Please place the cursor inside a table before running this macro.", vbExclamation
Exit Sub
End If
' Reference the selected table
Set sourceTable = Selection.Tables(1)
' Copy the table
sourceTable.Range.Copy
' Create a new document
Set newDoc = Documents.Add
' Paste the table into the new document
newDoc.Range.Paste
' Ensure the new document is active
newDoc.Activate
' Run your existing macro in the new document
Application.Run "NewMacros.Module1.AcronymAlyse"
MsgBox "Table copied and macro executed successfully.", vbInformation
End Sub