OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > Code Critique

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-07-2004, 11:52
dean29673
Guest
 
Posts: n/a
Default Numbering and Printing

I'm getting an compile error on the following code and can't figure it out. The error is at Set Rng1. I've used this same bit of code to serialize and print documents from Word and Excel. Why won't it work with Corel? Please help!

Sub numbering()
'
' numbering Macro
' Macro created 6/3/2004 by N505154
'
Dim Message As String, Title As String, Default As String, NumCopies As Long
Dim Rng1 As Range

' Set prompt.
Message = "Enter the number of copies that you want to print"
' Set title.
Title = "Print"
' Set default.
Default = "1"

' Display message, title, and default value.
NumCopies = Val(InputBox(Message, Title, Default))
SerialNumber = System.PrivateProfileString("C:\Settings.Txt", _
"MacroSettings", "SerialNumber")

If SerialNumber = "" Then
SerialNumber = 1
End If

Set Rng1 = ActiveDocument.Bookmarks("SerialNumber").Range
Counter = 0

While Counter < NumCopies
Rng1.Delete
Rng1.Text = Format(SerialNumber, "00#")
ActiveDocument.PrintOut
SerialNumber = SerialNumber + 1
Counter = Counter + 1
Wend

'Save the next number back to the Settings.txt file ready for the next use.
System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
"SerialNumber") = SerialNumber

'Recreate the bookmark ready for the next use.
With ActiveDocument.Bookmarks
.Add Name:="SerialNumber", Range:=Rng1
End With

End Sub
Reply With Quote
  #2  
Old 12-07-2004, 14:27
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Numbering and Printing

Simply because there is no such thing as "Bookmark" in CorelDRAW document and there is no object of type "Range" defined either. You can't just get a macro from Excel and excpect it to work in CorelDRAW.

What exactly you want CorelDRAW to do with your documents?

If I understand your Excel's code, you try to find a cell marked as "SerialNumber" and add some numbers to it, printing out the worksheet each time.

I guess the equivalent in CorelDRAW would be to find a text object named "SerialNumber" and change its contents to the formatted number...

Here is a sketchy code (you will need to modify it a bit):

Code:
Sub numbering()
Dim SerialNumber As Long
Dim Counter As Long
Dim sText As Shape

Set sText = ActiveDocument.ActivePage.Shapes("SerialNumber")
For Counter = 0 To 9
    sText.Text.Story = Format(SerialNumber + Counter, "00#") 
    ActiveDocument.PrintOut
Next Counter
I think you should get an idea from this...
Reply With Quote
  #3  
Old 12-07-2004, 16:07
dean29673
Guest
 
Posts: n/a
Default VBA for numbering and printing

Thanks for the reply. I created a text object within Corel and in the properties/internet box, named the bookmark "serialnumber". Used in Word or Excel, this code prompts the user for a specific number of copies to print, then sequently numbers each copy, saving the last number printed in a text file, that it retrieves each time to determine it's starting number. I was hoping it would work equally well within Corel Draw. I'll try tinkering with it again and let you know. Thanks again for the quick reply.
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
Auto Numbering Script DaFool CorelDRAW/Corel DESIGNER VBA 7 31-01-2005 11:27


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


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