Digilee
10-22-2012, 10:31 PM
Hi,
I have an Addin that is stored in the STARTUP folder, so it shows up when a document is loaded (it has a toolbar of its own). I use the addin to reformat a certain table found in the files. Included in the addin are several styles required by the reformat macro. My question is, how do I get these styles into a document that was not created with a template that contained these styles?
In other words, I want to copy several styles (not the whole set) from the addin.dotm to the ActiveDocument. I tried the following.
Sub CopyStyleFromAddIn()
Dim adin As AddIn
Dim addinPath As String
For Each adin In AddIns
If adin.Name = "Addin.dotm" Then
addinPath = adin.Path & Application.PathSeparator & adin.Name
End If
Next adin
Application.OrganizerCopy addinPath, ActiveDocument.FullName, "SiTableHeader", wdOrganizerObjectStyles
End Sub
This does not give an error when run, and in fact the style dialog box blinks like it is being refreshed, but the style does not show up. When I substitute a target template file, such as "doc3.dotm", it works fine (assuming doc3.dotm exists).
Is this not working because my target is a docx file or is the open document?
Any suggestions?
I have an Addin that is stored in the STARTUP folder, so it shows up when a document is loaded (it has a toolbar of its own). I use the addin to reformat a certain table found in the files. Included in the addin are several styles required by the reformat macro. My question is, how do I get these styles into a document that was not created with a template that contained these styles?
In other words, I want to copy several styles (not the whole set) from the addin.dotm to the ActiveDocument. I tried the following.
Sub CopyStyleFromAddIn()
Dim adin As AddIn
Dim addinPath As String
For Each adin In AddIns
If adin.Name = "Addin.dotm" Then
addinPath = adin.Path & Application.PathSeparator & adin.Name
End If
Next adin
Application.OrganizerCopy addinPath, ActiveDocument.FullName, "SiTableHeader", wdOrganizerObjectStyles
End Sub
This does not give an error when run, and in fact the style dialog box blinks like it is being refreshed, but the style does not show up. When I substitute a target template file, such as "doc3.dotm", it works fine (assuming doc3.dotm exists).
Is this not working because my target is a docx file or is the open document?
Any suggestions?