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-08-2008, 17:38
ProofingGuy
Guest
 
Posts: n/a
Default Open and/or Save File (that's in clipboard)

This is what seems like a reverse working of:
http://forum.oberonplace.com/showthread.php?t=5904


I do a lot of corel files showing people's products and a lot of times they want changes after they see the initial setup. so i need help with a macro that will do the following:

open the corel file that would be

Z:\GRAPHICS\Corel Artwork\ "first letter of clipboard string" \ "full clipboard string" \ "full clipboard sting".cdr

only other variations is ones that start with numbers which would open as such:

Z:\GRAPHICS\Corel Artwork\Numbers\ "full clipboard string" \ "full clipboard sting".cdr

and if there is nothing for the clipboard just return an error saying "nothing under this name"




having a macro to save like this with clipboard string would be great as well. thanks for all the help

Last edited by ProofingGuy; 01-08-2008 at 17:51.
Reply With Quote
  #2  
Old 02-08-2008, 18:16
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 Modified...

Here is some code to get you started, it is just a modified version of the code you linked to. Have fun.
Code:
Sub OpenFromClipboard()
    Dim ClipboardData As New DataObject
    Dim strName As String
    Dim strSubFolder As String
    
    'Test to see if their is text in the clipboard
    If Not Clipboard.DataPresent("Text") Then
        MsgBox "There is no text data in the Clipboard.", , "Open from Clipboard"
        Exit Sub
    End If
    
    'Get the Data from the Clipboard and assign to string
    ClipboardData.GetFromClipboard
    strName = ClipboardData.GetText()

    'Get the first letter of the FileName or if number
    strSubFolder = UCase(Left(strName, 1))
    If strSubFolder < "A" Or strSubFolder > "Z" Then
        strSubFolder = "Numbers"
    End If
    
    'Create the Full Path
    strName = "C:\Proofs\" & strSubFolder & "\" & strName & ".cdr"
    
    If Dir(strName) <> "" Then 'Test to see if the file exists
        OpenDocument (strName) 'If it does open it
    Else
        MsgBox "No Document Found" & Chr(13) & strName, , "Open from Clipboard"
    End If
End Sub
-Shelby
Reply With Quote
  #3  
Old 06-08-2008, 10:54
ProofingGuy
Guest
 
Posts: n/a
Default

now to the saving a file. the pdf saver macro ihave will return an error if the specific folder isnt there. can corel create folders?

i want to click it and save the clipboard text as such.


Z:\GRAPHICS\Corel Artwork\ "first letter of clipboard string" \ "full clipboard string" \ "full clipboard sting".cdr

and numbers like

Z:\GRAPHICS\Corel Artwork\Numbers\ "full clipboard string" \ "full clipboard sting".cdr



the A-Z and Numbers folder already exists but creating a folder and naming is the full string name that the corel file will be saved into is the problem. thanks shelby for all your help.
Reply With Quote
  #4  
Old 08-07-2011, 17:10
ProofingGuy
Guest
 
Posts: n/a
Default

I really enjoy this macro but there are a few things over the years that's happened. I have multiple setups.

Here's an example of something in my clipboard.
"01-filename - setup.pdf"

I want it to
ignore '01-'
ignore '.pdf'
make 'filename' = strSubFolder
make 'setup' = strSetup

Maybe something like this:
strName = "C:\Proofs\" & strSubFolder & "\" & strName & " - " & strSetup & ".cdr"

I just don't know how to setup the variables in the beginning to ignore the beginning or the end.
Reply With Quote
  #5  
Old 08-07-2011, 18:47
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
I didn't test it but added a few thing that might help you.

Code:
Option Explicit

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_SHIFT = &H10

Sub OpenFromClipboard()
    Dim ClipboardData As New DataObject
    Dim strName As String
    Dim strSubFolder As String
    
    'Test to see if their is text in the clipboard
    If Not Clipboard.DataPresent("Text") Then
        MsgBox "There is no text data in the Clipboard.", , "Open from Clipboard"
        Exit Sub
    End If
    
    'Get the Data from the Clipboard and assign to string
    ClipboardData.GetFromClipboard
    strName = ClipboardData.GetText()

    'Get the first letter of the FileName or if number
    strSubFolder = UCase(Left(strName, 1))
    If strSubFolder < "A" Or strSubFolder > "Z" Then
        strSubFolder = "Numbers"
    End If
    
    'Create the Full Path
    
    'hold shift to use alternate computer
    If GetShiftState() Then
        strName = "C:\Proofs\" & strSubFolder & "\" & strName & " - " & strSetup & ".cdr"
    Else
        strName = "C:\Proofs\" & strSubFolder & "\" & strName & ".cdr"
    End If
    
    
    
    If Dir(strName) <> "" Then 'Test to see if the file exists
        OpenDocument (strName) 'If it does open it
    Else
        MsgBox "No Document Found" & Chr(13) & strName, , "Open from Clipboard"
    End If
End Function

Private Function GetShiftState() As Boolean
    Call GetAsyncKeyState(VK_SHIFT)
    If GetAsyncKeyState(VK_SHIFT) <> 0 Then GetShiftState = True
End Function
~John
Reply With Quote
  #6  
Old 12-07-2011, 14:12
ProofingGuy
Guest
 
Posts: n/a
Default

Not sure what the shifting is doing. The top section puts itself in my previous macro and the ending statements is it's own thing.

I am getting an error.
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 get object information of CDR before open file? mitchellhu CorelDRAW/Corel DESIGNER VBA 1 11-03-2008 03:12
Automating closing open file by timer click101 CorelDRAW/Corel DESIGNER VBA 2 09-03-2006 05:19
file will not open mudhen General 3 03-02-2006 04:51
CorelDraw 8 error in DLL file - help !!! cannot open!!! Anonymous General 4 31-10-2004 15:52
Open file form ebarchiesi CorelDRAW/Corel DESIGNER VBA 1 13-09-2003 07:50


All times are GMT -5. The time now is 02:55.


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