![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]()
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 |
#3
|
|||
|
|||
![]()
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.
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Auto Numbering Script | DaFool | CorelDRAW/Corel DESIGNER VBA | 7 | 31-01-2005 11:27 |