OberonPlace.com Forums  

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

Thread Tools Search this Thread Display Modes
Old 25-01-2005, 08:26
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 Importing from dialog...

I have this problem, see... (CD12)
What I want to happen is,
1. Run Macro...
2. Dialog opens asking what file to import (only .ai)
3. macro opens template file from c:\
4. macro places and sizes .ai file on page.

The problem is, that just doesn't seem to happen. I tried to run it just in the module without a user form, but that doesn't seem to work and that is the way I would really like this to run. I don't really want to have to set up a form that is just going to get dismissed as soon as it comes up. below is the code that i am working on and the template file.
Option Explicit

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

    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
Private Sub ShowOpenFile()
Dim sPath As String
Dim GetBackEnd As String
Dim BrowseOpenFile As String
Dim n As String

    OFName.lStructSize = Len(OFName)
    OFName.hwndOwner = 0&
    OFName.hInstance = 0&
    OFName.lpstrFilter = "Adobe Illustrator Files" + Chr$(0) + "*.ai"
    OFName.lpstrFile = Space$(254)
    OFName.nMaxFile = 255
    OFName.lpstrFileTitle = Space$(254)
    OFName.nMaxFileTitle = 255
    sPath = GetBackEnd
    If sPath = vbNullString Then
        OFName.lpstrInitialDir = "C:\Documents and Settings\Artist\Desktop\"
        sPath = Left(sPath, InStrRev(sPath, "\") - 1)
        If Len(Dir(sPath, vbDirectory)) > 0 Then
            OFName.lpstrInitialDir = sPath
            OFName.lpstrInitialDir = "C:\Documents and Settings\Artist\Desktop\"
        End If
    End If
    OFName.lpstrTitle = "Select an AI File (*.ai)"
    OFName.flags = 0

    If GetOpenFileName(OFName) Then
        BrowseOpenFile = OFName.lpstrFile
        BrowseOpenFile = vbNullString
        MsgBox "No file Selected."
    End If
    'aiPath.Caption = BrowseOpenFile
        'n = InStr(BrowseOpenFile, vbNullChar)
        'If n <> 0 Then BrowseOpenFile = Left$(BrowseOpenFile, n - 1)

End Sub
Sub DoSomething()
    Dim doc As Document
    Dim Filter As ExportFilter
    Dim BrowseOpenFile As String
    Set doc = CreateDocumentFromTemplate("c:\PatternGuide.cdt")
    doc.Unit = cdrInch
    If BrowseOpenFile <> "" Then
        Dim s5 As Shape
        Dim x As Double, y As Double
        Dim nsy As Double
        ActiveLayer.Import BrowseOpenFile, 1283
        Set s5 = ActiveSelection
        s5.Move 0#, 0#
        ActiveDocument.ReferencePoint = cdrCenter
        s5.GetPosition x, y
        If s5.SizeWidth > (1.75 * s5.SizeHeight) Then
            nsy = (7 / s5.SizeWidth) * s5.SizeHeight
            s5.SetSizeEx x, y, , nsy
        ElseIf s5.SizeWidth < (1.75 * s5.SizeHeight) Then
            s5.SetSizeEx x, y, , 4
        End If
        s5.PositionX = 4.25
        s5.PositionY = 8.25
    End If
End Sub
Attached Files
File Type: zip PatternGuide.zip (22.3 KB, 557 views)
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote

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 13:37
Browse Dialog ddonnahoe CorelDRAW/Corel DESIGNER VBA 15 27-01-2004 11:51
Show "Edit text" Dialog? joexx CorelDRAW/Corel DESIGNER VBA 1 02-10-2003 19:30
dialog boxes jwknight CorelDRAW/Corel DESIGNER VBA 1 14-08-2003 12:46
Missing font dialog on import click101 CorelDRAW/Corel DESIGNER VBA 2 28-04-2003 12:32

All times are GMT -5. The time now is 10:58.

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