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 21-01-2004, 08:53
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default Browse Dialog

I am interested in creating a browse dialog command button, but have no idea where to begin. What I'm trying to do is give an optional command button that will allow the user to browse for an image file on their computer (or the network) that will be placed in the resluting document. I assume that I need a command button (DUH! LOL) and possibly a TextBox to visually store the filename for the end user until the form is dismissed. They only need to be able to select one item, if that makes a difference.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 21-01-2004, 09:10
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

I may even want to allow a list box or something to actually show the item, ie. jpg or gif, since that is what they will be primarily choosing from
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #3  
Old 21-01-2004, 09:20
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Have a look at the FileConverter Script

CorelDraw 11 comes with a FileConverter Script that shows much of what you are looking for. I learn best by example on there is lots to be learned from this one little script.

Shelby
Reply With Quote
  #4  
Old 21-01-2004, 12:54
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

I have figured out how it creates the Browse Window, however, it only browses for a certain folder. I want it to browse for a file and allow this file to be the only one selected.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #5  
Old 21-01-2004, 17:12
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

In this case you should use GetFileBox method of CorelScriptTools object which does exactly that:

Code:
Public Sub TestFileSelection()
    Dim FileName As String
    
    FileName = CorelScriptTools.GetFileBox("Text Files (*.txt)|*.txt", "Please select a text file to open", 1, "", "txt")

    If FileName <> "" Then
        MsgBox "File selected was: " & FileName
    End If
End Sub
Reply With Quote
  #6  
Old 21-01-2004, 19:10
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default

Alex’s answers are always so easy. I on the other hand tend to make things much more difficult then they need be.

Alex a question or two. The dialog your example opens says, “Save type as” and the buttons are Save and Cancel. Is there a way for it to be Open type as and the buttons Open and Cancel?

Here is a more complicated approach I found on another VBA newsgroup. Alex is this a bad approach to use? I have modified it a bit to filter for CDR files:

Code:
Private Declare Function GetOpenFileName Lib "comdlg32.dll" _
    Alias "GetOpenFileNameA" _
    (pOpenfilename As OPENFILENAME) As Long

Private Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
End Type

Sub ShowOpenFile()
Dim OFName As OPENFILENAME
Dim sPath As String

    OFName.lStructSize = Len(OFName)
    OFName.hwndOwner = 0&
    OFName.hInstance = 0&
    OFName.lpstrFilter = "CDR - CorelDRAW" + Chr$(0) + "*.cdr"
    OFName.lpstrFile = Space$(254)
    OFName.nMaxFile = 255
    OFName.lpstrFileTitle = Space$(254)
    OFName.nMaxFileTitle = 255
    sPath = GetBackEnd
    If sPath = vbNullString Then
        OFName.lpstrInitialDir = "c:\"
    Else
        sPath = Left(sPath, InStrRev(sPath, "\") - 1)
        If Len(Dir(sPath, vbDirectory)) > 0 Then
            OFName.lpstrInitialDir = sPath
        Else
            OFName.lpstrInitialDir = "c:\"
        End If
    End If
    OFName.lpstrTitle = "Open a CDR File (*.cdr)"
    OFName.flags = 0

    If GetOpenFileName(OFName) Then
        BrowseOpenFile = OFName.lpstrFile
        MsgBox BrowseOpenFile
    Else
        BrowseOpenFile = vbNullString
        MsgBox "No file Selected."
    End If
End Sub
Reply With Quote
  #7  
Old 21-01-2004, 21:01
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Quote:
Originally Posted by shelbym
Alex a question or two. The dialog your example opens says, “Save type as” and the buttons are Save and Cancel. Is there a way for it to be Open type as and the buttons Open and Cancel?
Oh, sorry, my mistake. The 3rd parameter should be set to 0 instead of 1 to show the Open dialog instead of Save.

Plust the very last parameter (two optional parameters not shown in the code above) can be used to specify different caption for Open/Save button.

Sorry about the confusion.

In fact, the methods of CorelScriptTools object is an adaptation of some of internal CorelScript commands which were in the language itself. GetFileBox is one of them. There are more. You can get more information on their parameters and usage on the following page: http://www.oberonplace.com/tutor/page7.htm

Please note that CorelScript's GetFolder command is not implemented in VBA's CorelScriptTools object even though the method is present.
Reply With Quote
  #8  
Old 22-01-2004, 07:56
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

I just realized that I didn't specify. I want this to be able to work in other VBA Capable programs, so I'm looking for something generic. What happened was, I created a form to use in CorelDRAW to fill in the blanks on our company order form. However, the salesforce doesn't have acces to Corel, but they do have access to MSWord. I am trying to convert this over to Word. I have everything but this "Browse for File" dialog thing down. I know this isn't a "Word" forum, but I was hoping there was something that VBA could let me do to access this that wasn't specifically application dependent.

Sean
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #9  
Old 22-01-2004, 09:37
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default

The code I posted above with with with Word. Infact that is were I got it from was a Word Forum. I tried it in Word 2003 and it works file. Word also has a simple way to do this, but it will not work in Draw. See code below:
Code:
Sub Main()

    Dim fd As FileDialog
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    Dim vrtSelectedItem As Variant

    With fd
        If .Show = -1 Then
            For Each vrtSelectedItem In .SelectedItems
                MsgBox "The path is: " & vrtSelectedItem
            Next vrtSelectedItem
        Else
        End If
    End With
    Set fd = Nothing

End Sub
Reply With Quote
  #10  
Old 22-01-2004, 14:55
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

I'm not really following you on this. I've tried using both sets of code and various changes to each, but can't seem to get it nailed down. Am I supposed to attach this to a cmdButton click or what?
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
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
format text dialog box implement graphicdesigner CorelDRAW/Corel DESIGNER VBA 5 22-12-2004 14:37
Save Dialog Box Mark CorelDRAW/Corel DESIGNER VBA 1 21-07-2004 07:15
Problem with opened dialog box Corel Draw 11 dergy CorelDRAW/Corel DESIGNER VBA 1 14-06-2004 11:04
Show "Edit text" Dialog? joexx CorelDRAW/Corel DESIGNER VBA 1 02-10-2003 20:30
Missing font dialog on import click101 CorelDRAW/Corel DESIGNER VBA 2 28-04-2003 13:32


All times are GMT -5. The time now is 20:19.


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