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 27-10-2004, 10:30
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 Document not open...

This should be an easy one, but I still haven't quite got a grip on MsgBox function.

I have a couple of macros that won't run unless there is an open document. How can I get a MsgBox that pops up stating "You need to have an active document to run this macro." and then dismisses with OK button instead of getting VB error code MsgBox.

Also, I have a group of button that run various macros and I was wondering if there is a way to "grey-out" the ones that can;t run in the current open or un-opened document state, such as the import and export buttons that don't work when no document is open.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 27-10-2004, 15:08
Seelenquell
Guest
 
Posts: n/a
Default

if documents.count > 0

i think, don´t have a corel here
Reply With Quote
  #3  
Old 27-10-2004, 15:55
drg
Guest
 
Posts: n/a
Default

Code:
Sub MySub
	On Error Goto 10

	' 
	' 
	'
	For q=1 to 1000
		Beep
	Next

Exit Sub
10
	MsgBox "Ops:" & err$
End Sub
:idea:
P.$.
=============================
Vote for Yanukovich V.F.
=============================
Reply With Quote
  #4  
Old 29-10-2004, 10:52
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
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 Example

Create a New form with 3 Command Buttons and use the following Code:

Code:
Private Sub UserForm_Initialize()

If Documents.Count = 0 Then CommandButton3.Enabled = False

End Sub

Private Sub CommandButton1_Click()

If Documents.Count = 0 Then
    MsgBox "Please Open a Document"
    Exit Sub
End If

If Documents.Count > 0 Then
    MsgBox "Number of Documents Open: " & Documents.Count
    Exit Sub
End If

End Sub

Private Sub CommandButton2_Click()

Dim doc As Document
Set doc = CreateDocument()

CommandButton3.Enabled = True

End Sub

Private Sub CommandButton3_Click()

ActiveLayer.CreateEllipse(0, 3, 5, 1).Fill.UniformColor.CMYKAssign 0, 100, 100, 0

End Sub
Button 1: When clicked will tell you how many documents you currently have open

Button 2: Will create a new document and Enable Button 3

Button 3: Is only enabled if a document is open, if it is will create an ellipse.
Reply With Quote
  #5  
Old 29-10-2004, 14:13
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Example

Also in CorelDRAW 11 and 12 you can just check the value of ActiveDocument property. If there is no document open, this property will return Nothing:

Code:
If ActiveDocument Is Nothing Then
    MsgBox "No document open", vbCritical
Else
    ' ... do something with the document ...
End If
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 form when i open my template diltech CorelDRAW/Corel DESIGNER VBA 1 10-01-2005 16:46
Creating new document problems ddonnahoe Code Critique 2 20-11-2004 17:11
New document creation problem ddonnahoe CorelDRAW/Corel DESIGNER VBA 2 20-11-2004 00:26
Copying objects to clipboard then closing document. CORNMEN CorelDRAW/Corel DESIGNER VBA 4 31-03-2003 09:52
Active document issues.. wbochar CorelDRAW/Corel DESIGNER VBA 2 19-03-2003 15:15


All times are GMT -5. The time now is 11:05.


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