OberonPlace.com Forums  

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

Thread Tools Search this Thread Display Modes
Old 30-07-2010, 07:49
bprice's Avatar
bprice bprice is offline
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default Filename Comparison

Been a long time since I have been in here! Hello to everyone!

Quick question... I think I am brain dead this morning... possibly because it's Friday and a long weekend is ahead of me!

I need to compare a filename at close to see if it's the same filename as when I opened the drawing... whats the easiest/best way to do this?

In addition, this needs to happen regardless of how many files might be open, or have been opened and closed.

Basically, what I am trying to do is if the filename is the same, a script will execute when I close... however if the filename is different (I've done a save-as) the script will not execute...


Any and all info is greatly appreciated!
Reply With Quote
Old 31-07-2010, 13:32
shelbym's Avatar
shelbym shelbym is offline
Senior Member
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,790
Blog Entries: 13
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 Filename

It is so good to see you again. Welcome back!

Here is my first stab at this. Basically, when the file is opened I save the Doc.Title (example.cdr) to the document.properties. Then when the file is closed, I check to see if the current title matches what it was when the document was opened. This should work no matter how many files are opened and closed. :-)

In your GMS file place the following code in the "ThisMacroStorage" section.

Private Sub GlobalMacroStorage_DocumentOpen(ByVal Doc As Document, ByVal FileName As String)
    Doc.Properties("CheckDocumentName", 1) = Doc.Title
End Sub

Private Sub GlobalMacroStorage_QueryDocumentClose(ByVal Doc As Document, Cancel As Boolean)
    If Doc.Properties.Exists("CheckDocumentName", 1) Then
        If Doc.Properties("CheckDocumentName", 1) = Doc.Title Then
            MsgBox "I am the same"
            'Do Something
        End If
    End If
End Sub
Again, this currently checks the title, if you want to see if the file is being saved to a new location you could use filename. :-)

Reply With Quote
Old 03-08-2010, 07:42
bprice's Avatar
bprice bprice is offline
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89

Thank you sir! It's been awhile since I have been around. We have been insanely busy here at work, and I haven't had a chance to create any little scripts in awhile! I'm a little rusty, and I actually missed it!

What you gave me works perfectly! It's exactly what I needed! As always, much appreciated!
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
Get Filename from imported file ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 01-06-2007 09:22
Filename without extension norbert_ds CorelDRAW/Corel DESIGNER VBA 1 18-04-2007 01:05
Thumbnails before filename signweld General 2 06-06-2006 08:34
save filename without extension and prn automation error olympiatr CorelDRAW/Corel DESIGNER VBA 5 20-10-2004 08:17
Insert Filename & Path pmills New product ideas 4 02-09-2003 06:20

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

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