OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Simple Import of file object (http://forum.oberonplace.com/showthread.php?t=24602)

dungbtl 02-03-2013 05:30

Simple Import of file object
 
Looking for a piece code that imports an object file.
this works but puts it where it originates:

Code:

Sub importgrommet()
ActiveLayer.Import "C:\@_Drop\pins.cdr"
End Sub

Instead of placing this object on page
Im looking to have it act like when you IMPORT and object.
The object is with the mouse and you get the choice where to place it.
You click and it drops in place. Not where it originally was made from.
Then i would assign a shortcut for it when needed.

Working with X4

Thanks All :D

AVP 02-03-2013 06:08

Simple Import of file object
 
try this

Code:

Sub importgrommet()
 On Error GoTo myerr
    ActiveDocument.ReferencePoint = cdrCenter
    Dim x As Double, y As Double
    Dim Shift As Long
    b = False
    b = ActiveDocument.GetUserClick(x, y, Shift, 10, False, cdrCursorWinCross)
    Optimization = True
    ActiveDocument.BeginCommandGroup "import"
    ActiveLayer.Import "C:\@_Drop\pins.cdr"
    ActiveShape.SetPosition x, y
myerr:
    ActiveDocument.EndCommandGroup
    Optimization = False
    ActiveWindow.Refresh
End Sub


dungbtl 02-03-2013 06:18

Seem to get a compile error. I found another post a while back...

Importing to "mouse click position"

I dont know what happens as I get errors. Seems like what im after.

But hopefully your code will do it

Quote:

Originally Posted by AVP (Post 37405)
try this

Code:

Sub importgrommet()
 On Error GoTo myerr
    ActiveDocument.ReferencePoint = cdrCenter
    Dim x As Double, y As Double
    Dim Shift As Long
    b = False  <---  Compile Error:  Can't find project or library
    b = ActiveDocument.GetUserClick(x, y, Shift, 10, False, cdrCursorWinCross)
    Optimization = True
    ActiveDocument.BeginCommandGroup "import"
    ActiveLayer.Import "C:\@_Drop\pins.cdr"
    ActiveShape.SetPosition x, y
myerr:
    ActiveDocument.EndCommandGroup
    Optimization = False
    ActiveWindow.Refresh
End Sub


Thanks !

AVP 02-03-2013 06:40

Code:

Sub importgrommet()
 On Error GoTo myerr
    ActiveDocument.ReferencePoint = cdrCenter
    Dim x As Double, y As Double, Shift As Long, b As Boolean
    b = False
    b = ActiveDocument.GetUserClick(x, y, Shift, 10, False, cdrCursorWinCross)
    Optimization = True
    ActiveDocument.BeginCommandGroup "import"
    ActiveLayer.Import "C:\@_Drop\pins.cdr"
    ActiveShape.SetPosition x, y
myerr:
    ActiveDocument.EndCommandGroup
    Optimization = False
    ActiveWindow.Refresh
End Sub


dungbtl 02-03-2013 06:49

PERFECT!
Made me day ...

Donuts and coffee down in the VIP room

Tell em Dungbtl sent ya :D

SteveDude 13-03-2013 09:00

Quote:

Originally Posted by dungbtl (Post 37404)
Looking for a piece code that imports an object file.
this works but puts it where it originates:

Code:

Sub importgrommet()
ActiveLayer.Import "C:\@_Drop\pins.cdr"
End Sub

Instead of placing this object on page
Im looking to have it act like when you IMPORT and object.
The object is with the mouse and you get the choice where to place it.
You click and it drops in place. Not where it originally was made from.
Then i would assign a shortcut for it when needed.

Thanks All :D

Shelby turned me on this...

Code:


Sub TestInteractiveImport()
    ActiveDocument.InteractiveImport "C:\@_Drop\pins.cdr"
End Sub


dungbtl 09-04-2013 13:34

Thanks Steve...

Im sure it works great for X6

im in X4 & 5

any chance for a cleaner code for that?

:goggles:


All times are GMT -5. The time now is 17:03.

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