![]() |
#1
|
||||
|
||||
![]()
This code is supposed to take info from the form for finished height and width and the sleeve size, and create a document that is (height x2 + sleeve size + .5 inches) in hieght and width is increased by 1 inch
Two problems. 1. The document doesn't get the .5" added to it and 2. The info bar still shows the document as 8.5"x11" Code:
Option Explicit Private Declare Function GetOpenFileName Lib "comdlg32.dll" _ Alias "GetOpenFileNameA" _ (pOpenfilename As OPENFILENAME) As Long Private Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type Private Function GetValue(ByVal sValue As String) As Integer If sValue = "" Then GetValue = 0 Else GetValue = Val(sValue) End If End Function Private Sub buttonCancel_Click() Unload Me End Sub Private Sub buttonOK_Click() If ValidateParams Then CreateVinylStreetBanner.Hide CreatePageLayout End If End Sub Private Sub BoxSpace_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If Not ((Chr(KeyAscii) >= 0 And Chr(KeyAscii) <= 9) Or (Chr(KeyAscii) = ".")) Then KeyAscii = 0 End If End Sub Private Function ValidateParams() As Boolean ValidateParams = True If (IsNumeric(boxWidth.Text) = False) Then GoTo ErrWidth If (IsNumeric(boxHeight.Text) = False) Then GoTo ErrHeight If (IsNumeric(boxSleeve.Text) = False) Then GoTo ErrSleeve Exit Function ErrWidth: MsgBox "Spacing not numeric : " & boxWidth.Text boxWidth.SetFocus ValidateParams = False Exit Function ErrHeight: MsgBox "Spacing not numeric : " & boxHeight.Text boxHeight.SetFocus ValidateParams = False Exit Function ErrSleeve: MsgBox "Spacing not numeric : " & boxSleeve.Text boxSleeve.SetFocus ValidateParams = False Exit Function End Function Private Sub ShowOpenFile() Dim OFName As OPENFILENAME Dim sPath As String Dim GetBackEnd As String Dim BrowseOpenFile As String Dim n As String OFName.lStructSize = Len(OFName) OFName.hwndOwner = 0& OFName.hInstance = 0& OFName.lpstrFilter = "Image Files" + Chr$(0) + "*.ai;*.cdr;*.eps;*.pdf;*.cmx" OFName.lpstrFile = Space$(254) OFName.nMaxFile = 255 OFName.lpstrFileTitle = Space$(254) OFName.nMaxFileTitle = 255 sPath = GetBackEnd If sPath = vbNullString Then OFName.lpstrInitialDir = "c:\SharedImages\" Else sPath = Left(sPath, InStrRev(sPath, "\") - 1) If Len(Dir(sPath, vbDirectory)) > 0 Then OFName.lpstrInitialDir = sPath Else OFName.lpstrInitialDir = "c:\SharedImages\" End If End If OFName.lpstrTitle = "Select an image File (*.ai), (*.cdr), (*.cmx), (*.eps), (*.pdf)" OFName.flags = 0 If GetOpenFileName(OFName) Then BrowseOpenFile = OFName.lpstrFile Else BrowseOpenFile = vbNullString MsgBox "No file Selected." End If End Sub Private Sub CreatePageLayout() Dim doc As Document Dim BrowseOpenFile As String Dim docH As Long Dim docW As Long Dim dw As Integer Dim dh As Integer Dim sl As Integer Dim sewn As Integer sewn = 0.5 dw = GetValue(boxWidth.Value) dh = GetValue(boxHeight.Value) sl = GetValue(boxSleeve.Value) docH = dh + dh + sl + sewn docW = dw + 1 Set doc = CreateDocument() doc.Unit = cdrInch 'MsgBox "W:" & docW & " H:" & docH & " Sleeve:" & sl With ActivePage .Orientation = cdrPortrait .SizeWidth = docW .SizeHeight = docH .PrintExportBackground = False .Bleed = 0# .Background = cdrPageBackgroundNone End With If checkAddFile.Value = True Then ShowOpenFile End If If BrowseOpenFile <> "" Then Dim s5 As Shape Dim x As Double, y As Double Dim nsy As Double ActiveLayer.Import BrowseOpenFile Set s5 = ActiveSelection s5.Move 0#, 0# ActiveDocument.ReferencePoint = cdrCenter s5.GetPosition x, y If s5.SizeWidth > (2.14 * s5.SizeHeight) Then nsy = (7.5 / s5.SizeWidth) * s5.SizeHeight s5.SetSizeEx x, y, , nsy ElseIf s5.SizeWidth < (2.14 * s5.SizeHeight) Then s5.SetSizeEx x, y, , 3.5 End If s5.PositionX = 6.797 s5.PositionY = 2.154 End If End Sub
__________________
Sean Waiting for a ride in the T.A.R.D.I.S. |
#2
|
||||
|
||||
![]()
I think you are doing everything correctly (at least from a quick glance), however are you sure the page size is not changing? You know that CorelDRAW can show either the size of the current page or the default document page (master page) depending on the settings in the property bar? Could it be that you are changing the current page size while viewing the size of the default page size?
Here are some earlier discussions on the issue for more details: - Property Bar Refresh - setsize or setpagesize, question... |
#3
|
|||
|
|||
![]()
Thanks Alex, this helped a lot. I'm sorry if I seemed like a nuisance on this topic, I was just giong crazy. Thanks again.
|
![]() |
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 |
New document creation problem | ddonnahoe | CorelDRAW/Corel DESIGNER VBA | 2 | 20-11-2004 00:26 |
Document not open... | ddonnahoe | CorelDRAW/Corel DESIGNER VBA | 4 | 29-10-2004 14:13 |
Generic code to process all shapes in a document | glennwilton | CorelDRAW/Corel DESIGNER VBA | 0 | 05-09-2003 03:13 |
Page selection and object moving problems | wbochar | CorelDRAW/Corel DESIGNER VBA | 1 | 15-04-2003 09:10 |
Active document issues.. | wbochar | CorelDRAW/Corel DESIGNER VBA | 2 | 19-03-2003 15:15 |