OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 24-05-2007, 06:15
norbert_ds
Guest
 
Posts: n/a
Default Userform

Hi all,

I'd like to create a multipage userform, each page is actually a different folders on a local drive. I'd like to poplate each of these pages with images saved in these folders. The tricky thing according to me is populating these pages automatically, thus the height of each page in the userform will change according to the number of images in the userform. Also the number of pages in the userform should increase if any folder is added in the local drive. Subsequently a click on each of these buttons should perform a certain task.

Can any of you guide me to something similar if it exists in this forum or any other similar documentation? Or if anyone knows how to do this?

Is there a better way to do this than via a multipage userform?

Thanks much!
Norbert
Reply With Quote
  #2  
Old 24-05-2007, 12:17
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

multipage seems ok

mp - multipage

Code:
Sub FillPage(mp As MSForms.MultiPage, ByVal folder As String)
   Const imgWidth! = 72, imgHeight! = 72, pad! = 3, labelHeight! = 25
   Dim i&, p As MSForms.Page, file$, x!, y!, pic As StdPicture
   
   On Error Resume Next
   If Right$(folder, 1) <> "\" Then folder = folder & "\"
   i = InStrRev(Left$(folder, Len(folder) - 1), "\")
   Set p = mp.Pages.Add(, Left$(folder, 3) & "...\" & Mid$(folder, i + 1, Len(folder) - i))
   
   file = Dir(folder & "*")
   x = pad: y = pad
   Do While Len(file)
      Set pic = Nothing
      Set pic = LoadPicture(folder & file)
      If Not pic Is Nothing Then
         With p.Controls.Add("Forms.Image.1")
            .Move x, y, imgWidth, imgHeight
            .BorderStyle = fmBorderStyleNone
            .Picture = pic
         End With
         With p.Controls.Add("Forms.Label.1")
            .Move x, y + imgHeight, imgWidth, labelHeight
            .Text = file
            .ControlTipText = file
         End With
         x = x + pad + imgWidth
         If x + imgWidth > p.InsideWidth Then
            x = pad
            y = y + imgHeight + labelHeight + pad
         End If
      End If
      file = Dir()
   Loop
   p.ScrollHeight = p.InsideHeight
   p.ScrollBars = IIf(p.ScrollHeight > p.InsideHeight, fmScrollBarsVertical, fmScrollBarsNone)
   End Sub
to check whether a folder is added, in form's code:
Code:
'top of form
private bExitRequest%
'................
Private Sub UserForm_Activate()
   Const baseFolder$ = "d:\"
   Dim prevCheck!, prevFolders$, file$
   prevFolders = vbCr
   Do While Not bExitRequest
      DoEvents
      If Timer - prevCheck > 1 Then ' 1 second passed
         '....use Dir() loop to see whether new folder is added
         file = Dir(baseFolder & "*", vbDirectory)
         Do While Len(file)
            'maybe additional check for Directory attribute is required
            If (GetAttr(baseFolder & file) And vbDirectory) <> 0 Then
               If InStr(prevFolders, vbCr & file & vbCr) = 0 Then
                  FillPage multipage1, baseFolder & file
               Else
                  prevFolders = prevFolders & file & vbCr
               End If
            End If
            file = Dir()
         Loop
         prevCheck = Timer
      End If
   Loop
   End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
   bExitRequest = True
   End Sub
Reply With Quote
  #3  
Old 29-05-2007, 19:24
norbert_ds
Guest
 
Posts: n/a
Default

Thanks very much for this wOxxOm!

Rather than use your code straight off, I am trying to understand it and may need some more help on this.

Appreciate this!

Regards
Norbert
Reply With Quote
  #4  
Old 01-06-2007, 01:05
norbert_ds
Guest
 
Posts: n/a
Default

Hi wOxxOm,

How do I get you code to run? I need to see what it does exactly!

Thanks a ton!
Norbert
Reply With Quote
  #5  
Old 01-06-2007, 03:50
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

then take a look at this small simple working macro which acts as a "render server for specified folder" - it checks every second if any new file is added into source folder, opens it if any, converts to eps in output folder, and so on

Macro: ThisMacroStorage.EPS_HotFolder
Run, and CAREFULLY set input folder to some empty one.
Keep the form running and copy any cdr into that specified folder - the macro will see it, open it, and export as eps into specified output folder

[fixed some strange error in code :-) ]
Attached Files
File Type: zip wx_HotEPS.zip (14.0 KB, 435 views)
Reply With Quote
  #6  
Old 10-01-2008, 22:29
norbert_ds
Guest
 
Posts: n/a
Default

Ho WoxxOm,

I get an error message on the code you posted.

The error message says:
Compile Error:
ByRef Argument Type Mismatch

And it comes on the code:
Code:
 FillPage multipage1, basefolder & file
I know its been a long time since I got back to you on this but I've been involved with some other stuff.

Thanks heaps.
Norbert
Reply With Quote
  #7  
Old 11-01-2008, 02:43
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

there's no such code in wx_HotEPS.

Ah, got it, you're talking of the above code, but multipage1 obviously stands for an existing form's control of type multipage. You should have one
Reply With Quote
  #8  
Old 13-01-2008, 20:20
norbert_ds
Guest
 
Posts: n/a
Default

Thanks for your response wOxxOm,

But things are not obvious to me since I am an absolute Newbie to VB.

I've done a bit of javascripting but not much of VB at all.

Could you explain please?

Thanks once again

Norbert
Reply With Quote
  #9  
Old 14-01-2008, 11:39
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

ehm, that code deal with multipage control on the form, so the control should be created by user in the form designer mode. The name multipage1 is the default name for newly created control
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
help: VBA minimize userform = frozen appwindow wOxxOm CorelDRAW/Corel DESIGNER VBA 1 30-04-2006 05:13
PhotoPaint9 VBA Problem woycek21 Corel Photo-Paint VBA 2 30-06-2005 02:10


All times are GMT -5. The time now is 16:02.


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