N
Numulguy
Version: 2008 I don't know if this is even possible. I have an existing VBA macro I use on Word for Windows and I need to get the equivalent functionality running on Word 2008 for Mac. This code needs to show/hide logos in the headers and will be used when the author decides to print onto letterhead or not.
The basic task breakdown is:
1. Toggle the value of an existing boolean custom document property
2. Search all graphic objects in the headers and if they have a specific text value, make the visibility of the graphic match the custom document propery.
The VBA code which does this is as follows.
Sub ToggleHeaderImages()
'Macro by Andrew Lockton
'Toggles the visibility of the logo image in the header
Dim aShape As Shape, bShow As Boolean, sPropName As String
sPropName = "ShowLogos"
If Not funCustPropExists(sPropName) Then
ActiveDocument.CustomDocumentProperties.Add Name:=sPropName, _
LinkToContent:=False, Value:=True, Type:=msoPropertyTypeBoolean
End If
bShow = Not ActiveDocument.CustomDocumentProperties(sPropName)
'All shapes in headers are stored in the first section irrespective of where they are viewed
For Each aShape In ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Shapes
If aShape.AlternativeText = "HeaderImage" Then aShape.Visible = bShow
Next aShape
'reset the value of the custom property
ActiveDocument.CustomDocumentProperties(sPropName) = bShow
End Sub
Function funCustPropExists(aProp As String) As Boolean
Dim aCustProp As Variant
funCustPropExists = False
For Each aCustProp In ActiveDocument.CustomDocumentProperties
If aCustProp.Name = aProp Then funCustPropExists = True
Next aCustProp
End Function
Is this something that Applescript is capable of? Can anyone point me in the right direction to create this script?
The basic task breakdown is:
1. Toggle the value of an existing boolean custom document property
2. Search all graphic objects in the headers and if they have a specific text value, make the visibility of the graphic match the custom document propery.
The VBA code which does this is as follows.
Sub ToggleHeaderImages()
'Macro by Andrew Lockton
'Toggles the visibility of the logo image in the header
Dim aShape As Shape, bShow As Boolean, sPropName As String
sPropName = "ShowLogos"
If Not funCustPropExists(sPropName) Then
ActiveDocument.CustomDocumentProperties.Add Name:=sPropName, _
LinkToContent:=False, Value:=True, Type:=msoPropertyTypeBoolean
End If
bShow = Not ActiveDocument.CustomDocumentProperties(sPropName)
'All shapes in headers are stored in the first section irrespective of where they are viewed
For Each aShape In ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Shapes
If aShape.AlternativeText = "HeaderImage" Then aShape.Visible = bShow
Next aShape
'reset the value of the custom property
ActiveDocument.CustomDocumentProperties(sPropName) = bShow
End Sub
Function funCustPropExists(aProp As String) As Boolean
Dim aCustProp As Variant
funCustPropExists = False
For Each aCustProp In ActiveDocument.CustomDocumentProperties
If aCustProp.Name = aProp Then funCustPropExists = True
Next aCustProp
End Function
Is this something that Applescript is capable of? Can anyone point me in the right direction to create this script?