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 19-04-2012, 09:32
byteme67's Avatar
byteme67 byteme67 is offline
Junior Member
 
Join Date: Apr 2010
Location: Fort Misery
Posts: 25
Default Userform Input placed into layout

I am working on a Userform that gathers information to be placed onto an already design layout. What I am gathering in this userform is the information like Proof No., Job Summary Description, Filename, Contact Person, Contact Company, Phone, Fax and Email. This information is then placed into the Proof Form sheet so I can them make a PDF file and email to the client.

If I might add to this situation I have a checkbox in the userform that asks if there are additional pages to the document being created. If that checkbox is checked then on my document I have a red check mark appear and print when the PDF is created.

Here are just a few samples of the Userform field names. txtProofNo, txtJobSummary, txtFilename, etc.

Here are my questions:
1) How do I get the userform txtXXXX fields into the document layout?
2) How do I get the checkbox on the userform for additional pages to make a check mark appear (already a layer by itself on the document) and print?
3) On one of the fields I have as a combolistbox how would I get a list of the open files for one of them to be selected in this combolistbox?

Thanks for any comments or directions to finding an answer.
Reply With Quote
  #2  
Old 19-04-2012, 12:55
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 UserForm Text

1) How do I get the userform txtXXXX fields into the document layout?

You can create the text like this:
Code:
 ActiveLayer.CreateArtisticText 0, 0, TextBox1.Text, , , "Arial", 12
2) How do I get the checkbox on the userform for additional pages to make a check mark appear (already a layer by itself on the document) and print?
Code:
If CheckBox1.Value Then ActivePage.Layers("MyCheckBox").Visible
3) On one of the fields I have as a combolistbox how would I get a list of the open files for one of them to be selected in this combolistbox?
Code:
Private Sub UserForm_Initialize()
    Dim doc As Document
    
    For Each doc In Application.documents
        ComboBox1.AddItem doc.Name
    Next doc
End Sub
That should get you started,

-Shelby
Reply With Quote
  #3  
Old 20-04-2012, 09:19
byteme67's Avatar
byteme67 byteme67 is offline
Junior Member
 
Join Date: Apr 2010
Location: Fort Misery
Posts: 25
Default

Thanks Shelby! It did point me in the right direction now I have an issue with a checkbox that I am trying to figure how to handle.
What I am trying to accomplish here is if the 'Additional Page' layer is visible then when the userform is initialized the Additional Page checkbox is checked and vice versus. It works, kind of, when I make sure the layer is not visible initially.

Code:
Private Sub chkAddlPgs_Click()
    
    If chkAddlPgs.Value = False Then
        ActivePage.Layer("Additional Page").Visible
        ActivePage.Layer("Additional Page").Printable
    End If
    
End Sub

Private Sub UserForm_Initialize()
    Dim doc As Document
    
    For Each doc In Application.Documents
        cmbFilename.AddItem doc.FilePath & doc.FileName
    Next doc
    
    'check if Additional Page layer is active
    ActivePage.Layers("Additional Page").Activate
    If ActiveLayer.Visible Then
        chkAddlPgs.Value = True
        Else
        chkAddlPgs.Value = False
    End If
    ActivePage.Layers("Proof Info").Activate
    
    
End Sub
Reply With Quote
  #4  
Old 20-04-2012, 13:24
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 Layers Visible

Since both values, the checkbox and Layer Visible are Boolean, you can simplify this by just setting them equal to each other.

As for your chkAddlePags_Click event, you forgot the s on Layers, and then need to set them equal to a value, again I would just set them equal to the checkbox value.
Code:
Private Sub chkAddlPgs_Click()
    ActivePage.Layers("Additional Page").Visible = chkAddlPgs.Value
    ActivePage.Layers("Additional Page").Printable = chkAddlPgs.Value
End Sub

Private Sub UserForm_Initialize()
    Dim doc As Document
    
    For Each doc In Application.documents
        cmbFilename.AddItem doc.FilePath & doc.FileName
    Next doc
    
    'check if Additional Page layer is active
    chkAddlPgs.Value = ActivePage.Layers("Additional Page").Visible
    ActivePage.Layers("Proof Info").Activate
End Sub
-Shelby
Reply With Quote
  #5  
Old 20-04-2012, 13:59
byteme67's Avatar
byteme67 byteme67 is offline
Junior Member
 
Join Date: Apr 2010
Location: Fort Misery
Posts: 25
Default

Thanks Shelby!!
Reply With Quote
  #6  
Old 29-05-2012, 11:37
byteme67's Avatar
byteme67 byteme67 is offline
Junior Member
 
Join Date: Apr 2010
Location: Fort Misery
Posts: 25
Default

What do I need to do to stop this from "pasting" outside of my document area? It works correctly on the first attempt but repositions after that. Any ideas? I can upload the GMS file and document if need be.

*edit*
Okay just reopened from the start and it does it initially. Sorry unable to upload document as it is 19MB. So if anyone that is willing to look at this I cam PM you the file and GMS let me know.

*edit again*
DOH!!! somehow the page alignment was off. So I double clicked the spot in the upper left corner of the two rulers and viola it works now. The question now would be how do I get this from not happening again. Like what is the code to use to make sure the lower left corner of the document is the 0,0 position.

Code:
Private Sub cmdOk_Click()
    'Ok button was clicked now do the following
    ActiveWindow.ActiveView.ToFitPage
    curDate = Format(Date, "Mmmm dd, yyyy")
    
    'check if any box is empty of information
    
    
    
    'fill the proof sheet with info provided
    ActivePage.Layers("Proof Info").Activate
    ActiveLayer.Shapes.All.Delete
    
    With ActiveLayer
        .CreateArtisticText 0.71488, 9.22521, txtProofNo.Text, , , "Swis721 BT", 9
        .CreateArtisticText 1.20034, 9.22419, curDate, , , "Swis721 BT", 9
        .CreateParagraphText 0.37646, 9.16376, 4.55017, 8.82941, txtJobSummary.Text, , , "Swis721 BT", 9
    End With
    
    If chkGeneric.Value = True Then
        txtFilename.Text = txtFilename.Text
        Else
        txtFilename.Text = cmbFilename.Text
    End If

    ActiveLayer.CreateArtisticText 0.7325, 8.68987, txtFilename.Text, , , "Swis721 BT", 7
    
    'Shapes.All.ApplyFill CreateRGBColor(255, 255, 255)
    
    'switch layers delete shapes and post new info
    ActivePage.Layers("Proof Area").Activate
    ActiveLayer.Shapes.All.Delete
    
    With ActiveLayer
        .CreateArtisticText 0.71068, 8.40261, txtContact.Text, , , "Swis721 BT", 9
        .CreateArtisticText 4.67731, 8.40507, txtBusiness.Text, , , "Swis721 BT", 9
        .CreateArtisticText 0.65028, 8.21527, txtPhone.Text, , , "Swis721 BT", 9
        .CreateArtisticText 2.86788, 8.21527, txtFax.Text, , , "Swis721 BT", 9
        .CreateArtisticText 5.28394, 8.21527, txtEmail.Text, , , "Swis721 BT", 9
    End With
    
    
    Unload Me

End Sub

Last edited by byteme67; 29-05-2012 at 12:05.
Reply With Quote
  #7  
Old 29-05-2012, 14:49
byteme67's Avatar
byteme67 byteme67 is offline
Junior Member
 
Join Date: Apr 2010
Location: Fort Misery
Posts: 25
Default

Okay posting to myself again. LOL After reading the help and locating something about DocumentOriginX = x I think this is the way to go.

But I am trying to reposition the Origin so that it is in the lower left corner. In the help it has this:

Code:
  Dim d As Document 
  Set d = ActiveDocument 
.
.
.
 d.DrawingOriginX = -d.ActivePage.SizeWidth / 2 
 d.DrawingOriginY = -d.ActivePage.SizeHeight / 2
But that is not doing what I was expecting it to do when I step through the code. Here is what I have which is essentially the same thing only verbose.

Code:
    ActiveDocument.DrawingOriginX = -ActiveDocument.ActivePage.SizeHeight / 2
    ActiveDocument.DrawingOriginY = -ActiveDocument.ActivePage.SizeWidth / 2
I also thought making DrawingOriginX = 0 would have reset it but that is not working either.
Reply With Quote
  #8  
Old 29-05-2012, 15:11
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

The tricky thing about checking your code is that most of it is based around your form which is not available to us.

One option is to provide the GMS file, another is to separate your code from your form. By which I mean - make a separate subroutine, like this:

Code:
Sub PlaceText(ByVal Text1 As String, ByVal Text2 As String, ByVal Text3 As String)
    With ActiveLayer
        .CreateArtisticText 0.71488, 9.22521, Text1, , , "Swis721 BT", 9
        .CreateArtisticText 0.71488, 9.22521, Text2, , , "Swis721 BT", 9
        .CreateArtisticText 0.71488, 9.22521, Text3, , , "Swis721 BT", 9
    End With
End Sub
This is just an example - the idea being you pass the needed parameters (those are the ByVal variables at the top) to your subroutine:

Code:
Sub ButtonSomething()
    PlaceText TextBox1.Value, TextBox2.Value, TextBox3.Value
End Sub
And it becomes separate from your form code. Then if you give us the code we can do something like:

Code:
Sub ButtonSomething()
    PlaceText "A","B","C"
End Sub
...and easily test it.

Also speaking of reusability having hardcoded values in your sub is an easy way to problems. I would do it somewhat like this, for example:

Code:
Sub Example()
    Dim X As Double, Y As Double, LineHeight As Double, FontSize as Byte
    X = ActivePage.LeftX
    Y = ActivePage.BottomY
    LineHeight = 0.3
    FontSize = 9
    
    With ActiveLayer
        .CreateArtisticText X, Y, Text1, , , "Swis721 BT", FontSize 
        .CreateArtisticText X, Y + LineHeight, Text2, , , "Swis721 BT", FontSize 
        .CreateArtisticText X, Y + LineHeight * 2, Text3, , , "Swis721 BT", FontSize 
    End With
End Sub
So you have a point you can easily set anywhere on the page and the rest of your text will be placed around it. Then you can use the LineHeight value to place the lines a certain distance apart which you can also easily change should you decide to change the font size or such. Basically I would make nearly anything into variables.

These are just general suggestions, but I hope they can help you a bit.
Reply With Quote
  #9  
Old 01-06-2012, 14:12
byteme67's Avatar
byteme67 byteme67 is offline
Junior Member
 
Join Date: Apr 2010
Location: Fort Misery
Posts: 25
Default

Hey there Joe thanks for the input. I will look into what you mentioned. In the mean time I have attached the GMS file. I believe because I have a userform they are Private Sub's. And it is detached from the local document.

The actual document is 19MB which I cannot upload because of the size. But if you wanted to look at it PM me and I can email it to you. Or use one of those storage web sites in the interim.

Thanks again!
Attached Files
File Type: gms ProofSheet.gms (38.0 KB, 240 views)
Reply With Quote
Reply

Tags
combobox, input to document, userform


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
Userform control default value noj CorelDRAW/Corel DESIGNER VBA 5 08-02-2012 11:44
Window Less UserForm Adrian_Juman CorelDRAW/Corel DESIGNER VBA 2 09-04-2011 10:18
Userform norbert_ds CorelDRAW/Corel DESIGNER VBA 8 14-01-2008 11:39
How to print to pdf file with imposition layout samhoods General 1 08-04-2006 23:45
Where does Imposition layout save itself samhoods General 1 29-03-2006 08:53


All times are GMT -5. The time now is 00:45.


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