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 01-02-2009, 03:36
inaph
Guest
 
Posts: n/a
Default Variable form controls based on file system

I am trying to dissect the code from another post to understand it better. It is a little more functionality than I think is needed for my purpose but it has elements that I want to implement.

Code Here

I changed
Code:
Private Sub UserForm_Activate()
   Const baseFolder$ = "d:\"
to
Code:
Private Sub UserForm_Activate()
   Const baseFolder$ = "C:\Laser\Parts\"
and moved
Code:
'top of form
private bExitRequest%
I get Runtime error 5 "invalid procedure call" in UserForm_Activate() on
Code:
file = Dir()
If I use this I get file not found error and the file variable in locals window is holding "Autoexec.bat"???
Code:
file = Dir("")
...tried alot different path strings in "dir()" but I'm still having trouble with it.

... and for more fun I'm developing using CD12 and Vista but it will likely run on x3 and xp.

What I'd like is to have my form start by reading the default directory (assigned in code) and return the folers as radio buttons. Resising of the form and repositioning of the radio buttons should happen programmatically in response to adding new folders in that directory. Upon selecting an option the function basicly does the same thing and presents a new set of radio controls. Only, when an option is selected this time, it returns a total of 5 variables. The selected subfolder name, the cdr file name, two images and a text file that are stored within that subfolder.

In this case it is

'default directory
C:\Laser\Parts\

'subdirectories
Partname 1
Partname 2
Partname 3

'files in subdirectories (returned as variables for further use)
Partname.cdr
Thumbnail.bmp
Fixture.bmp
Notes.txt

Please and Thank You
inaph
Reply With Quote
  #2  
Old 02-02-2009, 23:40
inaph
Guest
 
Posts: n/a
Default

I copied and pasted this code directly but there was no confirmation in the original post that indicated it works or that I am using it correctly. I'm just learning vba and my previous experience in programming is limited but I am a quick study at most things.

Looking through the docs on everything in this code, I cant seem to wrap my head around what "ByVal folder as String" means. I do not see "folder" set anywhere and "folder = whatever" dosent do anything.

When I run this code it does nothing and the locals window shows no values.
I get what it is supposed to do and I'm sure it is somethin I'm doing wrong, can someone point it out?


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
Reply With Quote
  #3  
Old 03-02-2009, 11:06
jemmyell jemmyell is offline
Senior Member
 
Join Date: Jan 2005
Location: Orange County, California, USA, Earth, Solar System, Milky Way Galaxy
Posts: 157
Default

Hi,

Folder is a parameter that is passed in to this routine. It is the full path to the directory (folder) that the routine will operate on. In the calling routine you can start out by hard coding a test scenario then make it dynamic when you understand how everything works.

-James
__________________
-James Leonard
CNC Inlay Guy - www.CorelDRAWCadCam.com
Reply With Quote
  #4  
Old 03-02-2009, 17:35
inaph
Guest
 
Posts: n/a
Default

Cool, thats what I needed, a breadcrumb to follow.

This got it somewhat working (for those learning like me)... although scroll bars are not showing up but I think I can figure it out.

Code:
Private Sub UserForm_Activate()
Call FillPage(UserForm1.MultiPage1, "C:\Laser\Parts\")
End Sub
Thank you James. I'm sure I'll have more questions as I go along. Hope to see you around!
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
How to access run-time created form controls ddonnahoe CorelDRAW/Corel DESIGNER VBA 3 14-02-2008 15:44
Object variable or with block variable not set.. m31uk3 Code Critique 2 26-12-2007 14:17
Adding controls to forms at runtime ddonnahoe CorelDRAW/Corel DESIGNER VBA 15 20-12-2005 14:59
object variable not found graphicdesigner CorelDRAW/Corel DESIGNER VBA 4 22-11-2004 19:13
Open file form ebarchiesi CorelDRAW/Corel DESIGNER VBA 1 13-09-2003 08:50


All times are GMT -5. The time now is 21:22.


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