OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old 02-09-2016, 07:19
ager ager is offline
Member
 
Join Date: Jul 2010
Location: Russia
Posts: 44
Default Is this forum still alive?

I found out how to solve my problem using a crutch (speaking in Russian ):
Code:
Dim FOp as Variant, FileAr as Variant

With CreateObject("Excel.Application")
 FOp = .GetOpenFileName(FileFilter:="(*.txt), .txt,)", MultiSelect:=True)
     If IsArray(FOp) Then
        ReDim FileAr(UBound(FOp))
        For i = LBound(FOp) To UBound(FOp)
            FileAr(i - 1) = FOp(i)
        Next i
    Else
        Exit Sub
    End If
End With
But my question is still topical. Because last opened file path is lost every time I use this code. In addition, when I updated my Corel up to CorelDRAW X8 64-bit I can't use Cyrillic symbols in VBA-code window. It's a pity...

Last edited by ager; 07-09-2016 at 09:03.
Reply With Quote
  #12  
Old 04-12-2016, 00:22
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,770
Blog Entries: 10
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 64-bit Version

Here is a 64-bit version. It is 64-bit only, but you may compare to the other to see what I changed:

Code:
Public Const OFN_ALLOWMULTISELECT = &H200&
Public Const OFN_EXPLORER = &H80000
Public Const OFN_FILEMUSTEXIST = &H1000&
Public Const OFN_HIDEREADONLY = &H4&
Public Const OFN_PATHMUSTEXIST = &H800&

Public Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias _
        "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
   
Public Type OPENFILENAME
    lStructSize As Long
    hwndOwner As LongPtr
    hInstance As LongPtr
    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 LongPtr
    lpTemplateName As String
End Type

Private Sub ShowFileOpenDialog(ByRef FileList As Collection)
    Dim OpenFile As OPENFILENAME
    Dim lReturn As Long
    Dim FileDir As String
    Dim FilePos As Long
    Dim PrevFilePos As Long

    With OpenFile
        .lStructSize = LenB(OpenFile)
        .hwndOwner = 0
        .hInstance = 0
        .lpstrFilter = "CDR - CorelDRAW (*.cdr)" + Chr(0) + "*.cdr" + _
            Chr(0) + "All Files (*.*)" + Chr(0) + "*.*" + Chr(0) + Chr(0)
        .nFilterIndex = 1
        .lpstrFile = String(4096, 0)
        .nMaxFile = LenB(.lpstrFile) - 1
        .lpstrFileTitle = .lpstrFile
        .nMaxFileTitle = .nMaxFile
        .lpstrInitialDir = "c:\"
        .lpstrTitle = "Open Drawings"
        .flags = OFN_HIDEREADONLY + _
            OFN_PATHMUSTEXIST + _
            OFN_FILEMUSTEXIST + _
            OFN_ALLOWMULTISELECT + _
            OFN_EXPLORER
        lReturn = GetOpenFileName(OpenFile)
        If lReturn <> 0 Then
            FilePos = InStr(1, .lpstrFile, Chr(0))
            If Mid(.lpstrFile, FilePos + 1, 1) = Chr(0) Then
                FileList.Add .lpstrFile
            Else
                FileDir = Mid(.lpstrFile, 1, FilePos - 1)
                Do While True
                    PrevFilePos = FilePos
                    FilePos = InStr(PrevFilePos + 1, .lpstrFile, Chr(0))
                    If FilePos - PrevFilePos > 1 Then
                        FileList.Add FileDir + "\" + _
                            Mid(.lpstrFile, PrevFilePos + 1, _
                                FilePos - PrevFilePos - 1)
                    Else
                        Exit Do
                    End If
                Loop
            End If
        End If
    End With
End Sub

Sub SelectFiles()
    Dim colFileList As New Collection
    Dim lngI As Long
    Dim strOutput As String

    ShowFileOpenDialog colFileList
    With colFileList
        If .Count > 0 Then
            strOutput = "The following files were selected:" + vbCrLf
            For lngI = 1 To .Count
                strOutput = strOutput + .Item(lngI) + vbCrLf
            Next
            MsgBox strOutput
        Else
            MsgBox "No files were selected!"
        End If
    End With
End Sub
-Shelby
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
Open File (that's in clipboard) ProofingGuy CorelDRAW/Corel DESIGNER VBA 5 12-07-2011 14:12
Open text edit dialog Albert CorelDRAW/Corel DESIGNER VBA 0 29-05-2009 08:40
Open & Save dialog of vista explorer by VBA aakkaarr CorelDRAW/Corel DESIGNER VBA 3 19-03-2009 05:23
open fill dialog diwin CorelDRAW/Corel DESIGNER VBA 2 21-05-2007 11:21
file will not open mudhen General 3 03-02-2006 04:51


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


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