OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 18-02-2010, 18:34
gorgo gorgo is offline
Senior Member
 
Join Date: Feb 2010
Posts: 169
Default Tumbnailer macro

Is there a way to set each field (ex:size, width) a certain with number and keep it set even after closing coreldraw?
Reply With Quote
  #2  
Old 18-02-2010, 18:58
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi,
Sure.
To save it use:

SaveSetting Statement
Saves or creates an application entry in the application's entry in the Windows registry or (on the Macintosh) information in the application’s initialization file.

Syntax


SaveSetting appname, section, key, setting

The SaveSetting statement syntax has these named arguments:

Part Description
appname Required. String expression containing the name of the application or project to which the setting applies. On the Macintosh, this is the filename of the initialization file in the Preferences folder in the System folder.
section Required. String expression containing the name of the section where the key setting is being saved.
key Required. String expression containing the name of the key setting being saved.
setting Required. Expression containing the value that key is being set to.


Remarks


An error occurs if the key setting can’t be saved for any reason.

Example:


Code:
SaveSetting "Thumbnailer", "Preferences", "width", frmMain.txtWidth.Value


To get it back when opening the form at a later date:


GetSetting Function

Returns a key setting value from an application's entry in the Windows registry or (on the Macintosh) information in the application’s initialization file.

Syntax


GetSetting(appname, section, key[, default])

The GetSetting function syntax has these named arguments:

Part Description

appname Required. String expression containing the name of the application or project whose key setting is requested. On the Macintosh, this is the filename of the initialization file in the Preferences folder in the System folder.
section Required. String expression containing the name of the section where the key setting is found.
key Required. String expression containing the name of the key setting to return.
default Optional. Expression containing the value to return if no value is set in the key setting. If omitted, default is assumed to be a zero-length string ("").

Remarks

If any of the items named in the GetSetting arguments do not exist, GetSetting returns the value of default.

Example:


Code:
Private Sub UserForm_Initialize()
txtWidth.Value = GetSetting("Thumbnailer", "Preferences", "width", 0.5)
End Sub
Make sure to put the GetSettiing in the UserForm_Initialize() area.

-John
Reply With Quote
  #3  
Old 19-02-2010, 10:45
gorgo2 gorgo2 is offline
Senior Member
 
Join Date: Feb 2010
Posts: 107
Default

Sounds great!....um, this makes me a little dizzy though. I'm not familiar with VB scripting so would you be so kind as to compile what you just told me??? Please.
Reply With Quote
  #4  
Old 19-02-2010, 12:13
gorgo2 gorgo2 is offline
Senior Member
 
Join Date: Feb 2010
Posts: 107
Default

Error: Ambiguous name detected.

code:
Code:
Private Sub cVMargin_Change()
    cfg.VMargin = cVMargin.GetValue()
    UpdateLayout
End Sub

Private Sub txtSource_Change()

End Sub

Private Sub txtWidth_Change()

SaveSetting "Thumbnailer", "Preferences", "width", frmMain.txtWidth.Value

End Sub

Private Sub UserForm_Initialize()
txtWidth.Value = GetSetting("Thumbnailer", "Preferences", "width", 0.5)
End Sub

Private Sub UserForm_Initialize()
    bProcessing = False
    Set cUnitBox = New clsUnitListBox
    cUnitBox.Init cbUnits, cfg.Unit
    
    Set cWidth = New clsUnitSpin
    cWidth.Init txtWidth, spnWidth, cfg.Width, 1, cUnitBox, lblWidthUnit, lblWidth, 0.1
    
    Set cHeight = New clsUnitSpin
    cHeight.Init txtHeight, spnHeight, cfg.Height, 1, cUnitBox, lblHeightUnit, lblHeight, 0.1

    Set cHSpacing = New clsUnitSpin
    cHSpacing.Init txtHSpacing, spnHSpacing, cfg.HSpacing, 1, cUnitBox, lblHSpacingUnit, lblHSpacing, 0
    
    Set cVSpacing = New clsUnitSpin
    cVSpacing.Init txtVSpacing, spnVSpacing, cfg.VSpacing, 1, cUnitBox, lblVSpacingUnit, lblVSpacing, 0

    Set cHMargin = New clsUnitSpin
    cHMargin.Init txtHMargin, spnHMargin, cfg.HMargin, 1, cUnitBox, lblHMarginUnit, lblHMargin, 0
    
    Set cVMargin = New clsUnitSpin
    cVMargin.Init txtVMargin, spnVMargin, cfg.VMargin, 1, cUnitBox, lblVMarginUnit, lblVMargin, 0
    
    Set cResolution = New clsIntSpin
    cResolution.Init txtResolution, spnResolution, cfg.Resolution, lblResolution, 36
    
    Set cFileType = New clsComboBox
    cFileType.Init cbFileType, 0, Array("Bitmaps (*.cpt;*.jpg;*.bmp;*.gif;*.tif*;*.jpeg;*.png;*.tga;*.psd;*.jp2;*.fpx)", _
                    "Vector Files (*.cdr;*.des;*.cmx;*.eps;*.ps;*.ai;*.wpg;*.wmf;*.emf;*.cgm;*.svg;*.dxf;*.dwg)", _
                    "CorelDRAW Files (*.cdr;*.des;*.cmx)", _
                    "All Files (*.*)")
                    
    cFileType_Change
    
    Set cColorMode = New clsComboBox
    cColorMode.Init cbColorMode, cfg.ColorMode, "Grayscale,RGB,CMYK", lblColorMode
    
    cSubFolders.Value = IIf(cfg.SubFolders, 1, 0)
    cSubFolders_Click
    
    cFolderCaptions.Value = IIf(cfg.FolderCaption, 1, 0)
    cRasterizeBefore.Value = IIf(cfg.RasterizeBefore, 1, 0)

    cRasterize.Value = IIf(cfg.Rasterize, 1, 0)
    cRasterize_Click
    
    cAddFileName.Value = IIf(cfg.AddCaption, 1, 0)
    cAddFileName_Click
    
    cAddFrame.Value = IIf(cfg.AddFrame, 1, 0)
    UpdateLayout
End Sub
Reply With Quote
  #5  
Old 19-02-2010, 12:31
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi,
Here's where you add it to save:

Code:
Private Sub cmOK_Click()
    Dim col As Collection
    Dim sFolder As String
    Dim sMask As String
    
    cfg.Resolution = cResolution.GetValue()
    SplitMask txtSource.Text, sFolder, sMask
    Set col = FindFiles(sFolder, sMask)
    If col.Count Then
        ImportAllFiles sFolder, col
        Unload Me
    Else
        MsgBox "No files found matching the specified mask", vbCritical
    End If
    'add save's here
    SaveSetting "Thumbnailer", "Preferences", "width", txtWidth.Value

End Sub
...and to get:

Code:
Private Sub UserForm_Initialize()
    'add get's here:
    txtWidth.Value = GetSetting("Thumbnailer", "Preferences", "width", 0.5)

    bProcessing = False
    Set cUnitBox = New clsUnitListBox
    cUnitBox.Init cbUnits, cfg.Unit
    
    Set cWidth = New clsUnitSpin
    cWidth.Init txtWidth, spnWidth, cfg.Width, 1, cUnitBox, lblWidthUnit, lblWidth, 0.1
    
    Set cHeight = New clsUnitSpin
    cHeight.Init txtHeight, spnHeight, cfg.Height, 1, cUnitBox, lblHeightUnit, lblHeight, 0.1

    Set cHSpacing = New clsUnitSpin
    cHSpacing.Init txtHSpacing, spnHSpacing, cfg.HSpacing, 1, cUnitBox, lblHSpacingUnit, lblHSpacing, 0
    
    Set cVSpacing = New clsUnitSpin
    cVSpacing.Init txtVSpacing, spnVSpacing, cfg.VSpacing, 1, cUnitBox, lblVSpacingUnit, lblVSpacing, 0

    Set cHMargin = New clsUnitSpin
    cHMargin.Init txtHMargin, spnHMargin, cfg.HMargin, 1, cUnitBox, lblHMarginUnit, lblHMargin, 0
    
    Set cVMargin = New clsUnitSpin
    cVMargin.Init txtVMargin, spnVMargin, cfg.VMargin, 1, cUnitBox, lblVMarginUnit, lblVMargin, 0
    
    Set cResolution = New clsIntSpin
    cResolution.Init txtResolution, spnResolution, cfg.Resolution, lblResolution, 36
    
    Set cFileType = New clsComboBox
    cFileType.Init cbFileType, 0, Array("CorelDRAW Files (*.cdr;*.des;*.cmx)", _
                    "Vector Files (*.cdr;*.des;*.cmx;*.eps;*.ps;*.ai;*.wpg;*.wmf;*.emf;*.cgm;*.svg;*.dxf;*.dwg)", _
                    "Bitmaps (*.cpt;*.jpg;*.bmp;*.gif;*.tif*;*.jpeg;*.png;*.tga;*.psd;*.jp2;*.fpx)", _
                    "All Files (*.*)")
    cFileType_Change
    
    Set cColorMode = New clsComboBox
    cColorMode.Init cbColorMode, cfg.ColorMode, "Grayscale,RGB,CMYK", lblColorMode
    
    cSubFolders.Value = IIf(cfg.SubFolders, 1, 0)
    cSubFolders_Click
    
    cFolderCaptions.Value = IIf(cfg.FolderCaption, 1, 0)
    cRasterizeBefore.Value = IIf(cfg.RasterizeBefore, 1, 0)

    cRasterize.Value = IIf(cfg.Rasterize, 1, 0)
    cRasterize_Click
    
    cAddFileName.Value = IIf(cfg.AddCaption, 1, 0)
    cAddFileName_Click
    
    cAddFrame.Value = IIf(cfg.AddFrame, 1, 0)
    UpdateLayout
End Sub
This should get you started.
-John
Reply With Quote
  #6  
Old 19-02-2010, 12:37
gorgo2 gorgo2 is offline
Senior Member
 
Join Date: Feb 2010
Posts: 107
Default

Thanks for the prompt reply John. I will give it a shot.
Reply With Quote
  #7  
Old 19-02-2010, 13:02
gorgo2 gorgo2 is offline
Senior Member
 
Join Date: Feb 2010
Posts: 107
Default

One more thing...I want to add the images to the ActiveDocument and not make a new one...how shall I go about this?
Reply With Quote
  #8  
Old 19-02-2010, 14:27
gorgo2 gorgo2 is offline
Senior Member
 
Join Date: Feb 2010
Posts: 107
Default

I have this way and it does not save my numbers.

Code:
Private Sub UserForm_Initialize()
    txtWidth.Value = GetSetting("Thumbnailer", "Frame1", "width", 0.5)
    txtWidth.Value = GetSetting("Thumbnailer", "Frame1", "height", 0.5)
    txtWidth.Value = GetSetting("Thumbnailer", "Frame2", "horizontal", 0.5)
    txtWidth.Value = GetSetting("Thumbnailer", "Frame2", "vertical", 0.5)
Also, what is the value .5 for?
Reply With Quote
  #9  
Old 19-02-2010, 21:59
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
When you also add the saveSettings function on the cmd button it will save your settings when you press the cmd button to start the macro. Next time the macro is run, the settings will be saved to the registry.

the 0.5 is just a default value incase the registry value is empty.

-John
Reply With Quote
  #10  
Old 19-02-2010, 23:08
gorgo gorgo is offline
Senior Member
 
Join Date: Feb 2010
Posts: 169
Default

I see.

I saw that the settings (values) were entered into the registry and now my problem is getting (GetSetting) that info when I run the macro again.

I entered the get's as you instructed but there is something wrong and I can't figure it out.

In the meantime, I figured out where the default values are and just entered my own numbers which I probably won't change in a long while since I'll only be using this macro for one specific purpose.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:14.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com