View Single Post
Old 02-07-2012, 08:35 AM   #440
Gauthier
Enthusiast
Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'Gauthier knows the difference between 'who' and 'whom'
 
Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
I made some Improvements to the handling of the Cover:
1 Store the cover path as a document property
2 Added it to the Ribbon as a splitbutton Add/Change + remove
3 Preview the cover within the Create dialog

Code for This:
CustomUI.xml into group FileData
Code:
<splitButton id="splitCoverImage" size="large">
	<button id="AddCoverImage" label="Add/Change Cover" imageMso="PictureInsertFromFilePowerPoint" onAction="ButtonClickMacro" getSupertip="CurrentValue" />
	<menu id="CoverImage" imageMso="PictureInsertFromFilePowerPoint" itemSize="normal" >
		<button id="RemoveCoverImage" label="delete" imageMso="OmsDelete" onAction="ButtonClickMacro" supertip="Remove Cover Image" />
	</menu>
</splitButton>
datBookCreatorProperties
Code:
Function getCoverPath() As String
    On Error GoTo Err_Clr

    getCoverPath = ThisDocument.CustomDocumentProperties("CoverPath")
    
    Exit Function
Err_Clr:
    getCoverPath = ""
End Function

Sub setCoverPath(szPath As String)

    On Error GoTo Err_Clr

    ThisDocument.CustomDocumentProperties("CoverPath") = szPath
    
    Exit Sub
Err_Clr:
    ThisDocument.CustomDocumentProperties.Add _
        Name:="CoverPath", LinkToContent:=False, _
        value:=szPath, _
        Type:=msoPropertyTypeString

End Sub
in frmCalibreAllFormat
In Form view:
Added a tab labeled "Cover" which containing a Picture Object named CoverImg
In Code View:

Modified part of Sub cmdCoverImageClick()
Added Sub shwPicture
Added a call to shwPicture at the end of Sub UserForm_Initialize()
Added a call to shwPicture in UserForm_Initialize()

Code:
Sub cmdCoverImageClick() 
...
    If bDisplayVal = -1 Then
        setCoverPath szPath + "\" + szDocName
        shwPicture
    Else
        Exit Sub
    End If
...
End Sub

Private Sub shwPicture()
    On Error GoTo MissingPic
    If Not IsNull(getCoverPath()) And Len(getCoverPath()) > 0 Then
        CoverImg.PictureSizeMode = fmPictureSizeModeZoom
        CoverImg.Picture = LoadPicture(getCoverPath(), 300, 200, Color)
    End If
    Exit Sub
MissingPic:
End Sub

Private Sub UserForm_Initialize()
...
    shwPicture 
End Sub
In RibbonTab
Added SubCurrentValue()
Code:
Sub ButtonClickMacro(ByVal control As IRibbonControl)
...
    Case Is = "RemoveCoverImage"
        setCoverPath ("")
    Case Is = "AddCoverImage"
        frmCalibreAllFormat.cmdCoverImage_Click
...
End Sub

'Callback for supertip: Show setting CurrentValue
Sub CurrentValue(control As IRibbonControl, ByRef supertip)
    Dim s As String
    Select Case control.ID
        Case Is = "CoverImage"
            s = getCoverPath()
            If Len(s) = 0 Then
                supertip = "No Cover Image Defined."
            Else
                supertip = "Current Cover: " + s
            End If
        Case Is = "SetAuthor"
            supertip = ActiveDocument.BuiltInDocumentProperties(wdPropertyAuthor)
        Case Is = "SetBookTitle"
            supertip = ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle)
    End Select
End Sub
I've also experimented with dynamic screentip and supertip in the ribbon.
However, I've not found yet how to trigger an update, the value is initialized correctly but latter change are not updated in the ribbon.

I have also found a useful reference on CustomUI specifications:
http://msdn.microsoft.com/en-us/libr...ffice.12).aspx
(There is a link to a pdf about 550 pages)

I'm also working on revamping the filename and Save To
with placeholder inspired from downThemAll
*author*, *sortauthor*, *fmt*, *title*
Gauthier is offline   Reply With Quote