|
|
#436 |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
|
Making drop down in the ribbonUI is not very difficult, I remember doing it for some access project.
<group ...> <menu id="..." label="" imageMso="..." itemSize="..." > <button ... /> <button ... /> </menu> </group> Creating a button on the fly is not possible, at best you can hide and show those you defined in the Custom UI.xml Last edited by Gauthier; 02-04-2012 at 06:10 PM. |
|
|
|
|
|
#437 | ||
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,671
Karma: 12205348
Join Date: Mar 2008
Device: Galaxy S, Nook w/CM7
|
Quote:
I've updated the BC 2007 with your updates. There where a few differences in the code you suggested and what I used here is a list below. Also would you please download the zip I've attached to this post and see if it works in your MS Word 2010 DIFF Used Code:
#If Win64 Then instead of #If VBA7 Then >>> I think there was a bug in the code you provded Code:
strPFPath = VBA.Environ("ProgramFiles(x86)")
If strPFPath = "" Then
strPFPath = VBA.Environ("ProgramFiles")
End If
setCalibrePath strPFPath + "\Calibre"
End If
strPFPath = VBA.Environ("ProgramFiles(x86)") Code:
If strPFPath = "" Then
strPFPath = VBA.Environ("ProgramFiles")
End If
setCalibrePath strPFPath + "\Calibre"
Also I removed the Sleep function since it was not used in the code. Quote:
Question is there any way I could group a button and menu item together so I could get <Word Wrap ...v> Where if the user presses the word "Word Wrap a method is executed and if the user presses the "v" menu button a drop down menu appears. For further reference the "Add-Ons" ribbon has the features I'm looking for =X= Last edited by =X=; 02-06-2012 at 07:13 PM. Reason: Added file |
||
|
|
|
| Advert | |
|
|
|
|
#438 | |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
|
Quote:
Code:
<splitButton id="splitButton" size="large" >
<button id="button" imageMso="HappyFace" label="Split Button" />
<menu id="menu">
<button id="button1" label="Button 1" />
<button id="button2" label="Button 2" />
</menu>
</splitButton>
|
|
|
|
|
|
|
#439 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,671
Karma: 12205348
Join Date: Mar 2008
Device: Galaxy S, Nook w/CM7
|
Okay I'll give it a shot.
Also one thing I forgot to mention was was that the multiple selection of files did not allow one to control the prefer on which they where imported. Word seemed to import biased on the last modified date. |
|
|
|
|
|
#440 |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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> 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 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
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
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* |
|
|
|
| Advert | |
|
|
|
|
#441 | |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
|
Quote:
The order is in Fact the order in which the files appears in the import dialog. If you sort the dialog by name, they are imported sorted by name. If you sort by date, they are imported sorted by date. If unfortunately, the file order is not a file system order your need to import them one by one or create another property on which to sort. Last edited by Gauthier; 02-07-2012 at 09:38 AM. |
|
|
|
|
|
|
#442 |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
|
Having to go multiple time from the saved word document to the create eBook, losing each time the information I filled in is a real pain.
Is there a good reason not to link more of the form properties to the document properties and system properties? Adding a reset to default button could cleanup user errors... vba frm _Activate vs _Initialize Using the cancel button on the form and then clicking "Create eBook" will trigger an activate event. Using the close button on the form and than clicking "Create eBook" will trigger an Initialize event followed by an activate event. Thus code present in Activate need not to be in Initialize I would however, merge both and rely more heavily on datBookCreatorProperties. |
|
|
|
|
|
#443 | ||
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,671
Karma: 12205348
Join Date: Mar 2008
Device: Galaxy S, Nook w/CM7
|
Quote:
Quote:
I think the request you are asking for is reasonable, I too found losing my document metadata annoying. But we'll have to find a way to store that information per document and not to the template (honestly I did not spend too much time looking for alternatives). =X= Last edited by =X=; 02-07-2012 at 02:11 PM. Reason: added quote |
||
|
|
|
|
|
#444 |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
|
More Clean Up of Old Code
in datBookCreatorProperties replace Code:
' GLOBAL VARIABLES
Function cUDEF() As Integer
cUNDEF = 0
End Function
Function cEPUB() As Integer
cEPUB = 1
End Function
Function cIMP() As Integer
cIMP = 2
End Function
Function cLIT() As Integer
cLIT = 3
End Function
Function cLRF() As Integer
cLRF = 4
End Function
Function cMOBI() As Integer
cMOBI = 5
End Function
Function cPDB() As Integer
cPDB = 6
End Function
Function cPDF() As Integer
cPDF = 7
End Function
Code:
' GLOBAL VARIABLES Public Const cUDEF As Integer = 0 Public Const cEPUB As Integer = 1 Public Const cIMP As Integer = 2 Public Const cLIT As Integer = 3 Public Const cLRF As Integer = 4 Public Const cMOBI As Integer = 5 Public Const cPDB As Integer = 6 Public Const cPDF As Integer = 7 Code:
'Devices Public Const cDEFAULT As Integer = 0 Public Const cSONY As Integer = 1 Public Const cMSREADER As Integer = 2 Public Const cMOBIPOCKET As Integer = 3 Public Const cHANLINV3 As Integer = 4 Public Const cCYBOOKG3 As Integer = 5 Public Const cKINDLE As Integer = 6 Public Const cSONYLND As Integer = 7 Public Const cKINDLEDX As Integer = 8 |
|
|
|
|
|
#445 |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
|
Cleanup of get, set prefix
Add a Class Module Named Param Code:
Dim ParamName As String
Dim ParamType As Long
Dim ParamValue As Variant
Dim ParamDefault As Variant
Dim ParamLocation As Long
Dim ParamAutoSave As Boolean
Dim ParamControlId As String
Dim isSet As Boolean
Private Sub Class_Initialize()
isSet = False
End Sub
Public Property Get Default() As Variant
Default = ParamDefault
End Property
Public Property Let Default(v As Variant)
ParamDefault = v
End Property
Public Property Get Value() As Variant
If isSet Then
Value = ParamValue
Else
Value = ParamDefault
End If
End Property
Public Property Let Value(v As Variant)
isSet = True
ParamValue = v
If ParamAutoSave Then
Save
End If
If Len(ParamControlId) > 0 Then
UpdateControl ParamControlId
End If
End Property
Public Sub Define(PropName As String, Optional PropDefaultValue As Variant = "", Optional PropType As Long = msoPropertyTypeString, Optional SaveTo As Long = pLocationVolatile, Optional AutoSave As Boolean = False, Optional RibbonControlId As String = "")
ParamName = PropName
Default = PropDefaultValue
ParamType = PropType
ParamLocation = SaveTo
ParamAutoSave = AutoSave
ParamControlId = RibbonControlId
Read
End Sub
Public Sub Save()
On Error Resume Next
Select Case ParamLocation
Case Is = pLocationVolatile
'do not save
Case Is = pLocationSystem
SaveSetting "BookCreator", "Parameters", ParamName, CStr(ParamValue)
Case Is = pLocationDocument
ActiveDocument.CustomDocumentProperties(ParamName) = ParamValue
If Err <> 0 Then
ActiveDocument.CustomDocumentProperties.Add _
Name:=ParamName, LinkToContent:=False, _
Value:=ParamValue, _
Type:=ParamType
End If
Case Is = pLocationTemplate
ThisDocument.CustomDocumentProperties(ParamName) = ParamValue
If Err <> 0 Then
ThisDocument.CustomDocumentProperties.Add _
Name:=ParamName, LinkToContent:=False, _
Value:=ParamValue, _
Type:=ParamType
End If
End Select
End Sub
Private Sub Read()
On Error Resume Next
Select Case ParamLocation
Case Is = pLocationVolatile
'Revert to the default value
isSet = False
Case Is = pLocationSystem
'We Only Get a String here
ParamValue = GetSetting("BookCreator", "Parameters", ParamName)
If Len(ParamValue) > 0 Then
'A Value was stored, convert to the defined type.
isSet = True
Select Case ParamType
Case Is = msoPropertyTypeBoolean
ParamValue = CBool(ParamValue)
Case Is = msoPropertyTypeNumber
ParamValue = CLng(ParamValue)
Case Is = msoPropertyTypeString
'Nothing to Do
End Select
End If
Case Is = pLocationDocument
'According to the doc, it is already correctly typed.
ParamValue = ActiveDocument.CustomDocumentProperties(ParamName)
If Err = 0 Then 'The CustomDocumentProperty named ParamName existed
isSet = True
End If
Case Is = pLocationTemplate
'According to the doc, it is already correctly typed.
ParamValue = ThisDocument.CustomDocumentProperties(ParamName)
If Err = 0 Then 'The CustomDocumentProperty named ParamName existed
isSet = True
End If
End Select
'Debug.Print "Param::Read ParamName:=" + ParamName + ", Value:=" + CStr(ParamValue)
End Sub
'Erase the Parameter Value from its storage.
Public Sub Reset()
Dim docProp As DocumentProperty
On Error Resume Next
isSet = False
Select Case ParamLocation
Case Is = pLocationVolatile
'Was Never saved, nothing to do
Case Is = pLocationSystem
'Remove from registry
DeleteSetting "BookCreator", "Parameters", ParamName
Case Is = pLocationDocument
'Remove from Custom Document Properties
docProp = ActiveDocument.CustomDocumentProperties(ParamName)
docProp.Delete
Case Is = pLocationTemplate
'Remove from Custom Document Properties
docProp = ThisDocument.CustomDocumentProperties(ParamName)
docProp.Delete
End Select
End Sub
Code:
'Some constant for Parameter Location
Public Const pLocationVolatile As Long = 0 'Parameter is not saved
Public Const pLocationSystem As Long = 1 'Parameter is saved to the HKCU Registry
Public Const pLocationDocument As Long = 2 'Parameter is saved to The document
Public Const pLocationTemplate As Long = 3 'Parameter is saved to The template
' CONFIGURATION VARIABLES
Public CalibrePath As Param
Public BaseFont As Param
Public BaseFontEpub As Param
Public BaseFontLIT As Param
Public WordSpaceLRF As Param
Public HeaderFormat As Param
Public Margin_Top As Param
Public Margin_Bottom As Param
Public Margin_Left As Param
Public Margin_Right As Param
Public LinkLevel As Param
Public ImpDeviceType As Param
Public BC_FIRST_RUN As Param
Public BookCreatorVersion As Param
Public AdditionalParam As Param
Public IMPAdditionalParam As Param
Public BookCreatorBuildVersion As Param
Public LocationPATH As Param
Public LocationSaveOption As Param
Public AutoSaveTemplate As Param
Public eBookReaderSaveOption As Param
Public eBookReaderPath As Param
Public DebugON_OFF As Param
Public InputProfile As Param
Public OutputProfile As Param
Public DisableJustify As Param
Public CoverImage As Param
Sub InitParams()
Set DebugON_OFF = New Param
DebugON_OFF.Define "DebugON_OFF", False, msoPropertyTypeBoolean, pLocationSystem, True
Set CalibrePath = New Param
CalibrePath.Define "CalibrePath", DefaultCalibrePath, msoPropertyTypeString, pLocationSystem, True
Set BaseFont = New Param
BaseFont.Define "BaseFont", "8", msoPropertyTypeString, pLocationDocument
Set BaseFontEpub = New Param
BaseFontEpub.Define "BaseFontEpub", "80", msoPropertyTypeString, pLocationDocument
Set BaseFontLIT = New Param
BaseFontLIT.Define "BaseFontLIT", "8", msoPropertyTypeString, pLocationDocument
Set WordSpaceLRF = New Param
WordSpaceLRF.Define "WordSpaceLRF", "2.0", msoPropertyTypeString, pLocationDocument
Set HeaderFormat = New Param
HeaderFormat.Define "HeaderFormat", """%t""", msoPropertyTypeString, pLocationDocument
Set Margin_Top = New Param
Margin_Top.Define "Margin_Top", "10", msoPropertyTypeString, pLocationDocument
Set Margin_Bottom = New Param
Margin_Bottom.Define "Margin_Bottom", "0", msoPropertyTypeString, pLocationDocument
Set Margin_Left = New Param
Margin_Left.Define "Margin_Left", "10", msoPropertyTypeString, pLocationDocument
Set Margin_Right = New Param
Margin_Right.Define "Margin_Right", "10", msoPropertyTypeString, pLocationDocument
Set LinkLevel = New Param
LinkLevel.Define "LinkLevel", 1, msoPropertyTypeNumber, pLocationDocument
Set ImpDeviceType = New Param
ImpDeviceType.Define "ImpDeviceType", 2, msoPropertyTypeNumber, pLocationDocument
Set BC_FIRST_RUN = New Param
BC_FIRST_RUN.Define "BC_FIRST_RUN", True, msoPropertyTypeBoolean, pLocationDocument
Set BookCreatorVersion = New Param
BookCreatorVersion.Define "BookCreatorVersion", "1.5", msoPropertyTypeString, pLocationDocument
Set AdditionalParam = New Param
AdditionalParam.Define "AdditionalParam", "", msoPropertyTypeString, pLocationDocument
Set IMPAdditionalParam = New Param
IMPAdditionalParam.Define "IMPAdditionalParam", "", msoPropertyTypeString, pLocationDocument
Set BookCreatorBuildVersion = New Param
BookCreatorBuildVersion.Define "BookCreatorBuildVersion", 15, msoPropertyTypeNumber, pLocationDocument
Set LocationPATH = New Param
LocationPATH.Define "LocationPATH", "", msoPropertyTypeString, pLocationDocument
Set LocationSaveOption = New Param
LocationSaveOption.Define "LocationSaveOption", "", msoPropertyTypeString, pLocationDocument
Set AutoSaveTemplate = New Param
AutoSaveTemplate.Define "AutoSaveTemplate", True, msoPropertyTypeBoolean, pLocationDocument
Set eBookReaderSaveOption = New Param
eBookReaderSaveOption.Define "eBookReaderSaveOption", False, msoPropertyTypeBoolean, pLocationDocument
Set eBookReaderPath = New Param
eBookReaderPath.Define "eBookReaderPath", "", msoPropertyTypeString, pLocationDocument
Set InputProfile = New Param
InputProfile.Define "InputProfile", cDEFAULT, msoPropertyTypeNumber, pLocationDocument, True
Set OutputProfile = New Param
OutputProfile.Define "OutputProfile", cDEFAULT, msoPropertyTypeNumber, pLocationDocument, True
Set DisableJustify = New Param
DisableJustify.Define "DisableJustify", False, msoPropertyTypeBoolean, pLocationDocument, True
Set CoverImage = New Param
End Sub
getSomeParam -> SomeParam.Value setSomeParam X -> SomeParam.Value = X That will make form data persistence more easy to manage and also save about 40KB from the file. The Default Values also clean up the INITIALIZE: Code:
Sub INITALIZE()
'________________________________________________
' NAME: INITALIZE
' AUTHOR: =X=
' DESCRIPTION: Initalizes BookCreator application
' for the very first run.
' HISTORY:
' DATE: 09/08/2008
'________________________________________________
InitParams
If BC_FIRST_RUN.Value = True Then
CreateToolBox True
BC_FIRST_RUN.Value = False
End If
End Sub
Last edited by Gauthier; 02-08-2012 at 05:45 PM. |
|
|
|
|
|
#446 | |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
|
Quote:
Code:
ThisDocument.CustomDocumentProperties("SomeParam")
Saving anything to the Template except for some style definition is probably a bad Idea. It may lead to corruption of the Template (I experienced one today, where creating a new document on the template or trying to open it crashed Word. The Template autoSave on exit should probably be Off. It would probably be best to Prevent editing and running the Macros from the opened template Last edited by Gauthier; 02-07-2012 at 03:49 PM. |
|
|
|
|
|
|
#447 | |
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
|
Quote:
I'll correct the Post Above to allow save to HKCU, Document and Template |
|
|
|
|
|
|
#448 | |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,671
Karma: 12205348
Join Date: Mar 2008
Device: Galaxy S, Nook w/CM7
|
I haven't had a chance to apply some of your changes. I'd like to test out the recommended changes on Word2003. And I only have that on my home computer.
Unfortunately I have neither time at work or home at the moment. Also I'm staring to find it difficult to track some of your changes. I'm wonder if you can just post the exported BAS files and I can run a diff to see all your changes. It will make it easier for us to shared code. It should reduce the chances of typos as well and the chance that you might have omitted a change. Quote:
Yep I like the idea of being able to read and write to the HKCU, Doc, Template based on the type of data we are saving. Not sure if I posted this already but Kovid has confirmed that we can use HKEY_LOCAL_MACHINE\SOFTWARE\calibre\Installer\Inst allPath to determine the path where calibre is installed. |
|
|
|
|
|
|
#449 |
|
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 300
Karma: 1006538
Join Date: Jul 2008
Device: Kindle Paperwhite (11th Gen)
|
Wow,
I havent seen this level of frenzied updating for a long time !! You go guys ! I looke forward to seeing the end product and being able to put it to use. Thanks for the hard work being put into this! |
|
|
|
|
|
#450 | |||
|
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 25
Karma: 10000
Join Date: Jan 2012
Device: kindle
|
Quote:
Quote:
I have choosen a GNUv3 Licence. If that bother you, I suppose it is possible to shut it down, before we upload code to it. http://code.google.com/p/word-ebook-creator/ If you can send me your gmail address to gvanvreckem AT gmail.com, I'll add you as owner. Quote:
So the Active Document should give us identification The only way to screw up is to switch to another document during the generation, but everything is already passed as function parameter there. I'll check to see if the Module variables instance are at the document level, as I tough. That's not present on my system I did an Uninstall of Calibre and installed again in another folder to be sure and it's still not there. Last edited by Gauthier; 02-09-2012 at 10:08 AM. |
|||
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bookcreator | MalcolmFranks | Introduce Yourself | 8 | 10-13-2010 10:49 PM |
| BookCreator 3.0 Beta | =X= | Workshop | 43 | 11-21-2009 12:08 AM |
| New Update BookCreator v2.6 | =X= | Workshop | 2 | 09-22-2009 06:04 AM |
| BookCreator v2.5: Just Released | =X= | Workshop | 0 | 09-28-2008 06:40 PM |
| BookCreator v2.0 Released (Book Creating tool) | =X= | Workshop | 1 | 09-15-2008 06:01 PM |