Create Rectangle Macro

Hi.

I am attempting to create a rectangle of a specified size at a specified location. I have specified millimeters as the units. The rectangle size is 150mm wide by 40mm high. The page x,y location is 325, 240. I can get the script to add the rectangle, but it is placed at the bottom left corner of the page and is really small. The macro appears to be ignoring my specified location and size. I have used both create rectangle and create rectangle 2 commands without success. I run my macros outside of Corel Draw as vbs files. Detailed below is my macro:

Dim Software

Dim ActivePage

Dim Page

Dim Layer

Dim Shape

Set Software = CreateObject(CorelDraw)

With Software.OpenDocument(FileName)

.Activate

.Unit = cdrMillimeter

.ReferencePoint = cdrCenter

Set ActivePage = .Pages.First

ActivePage.Layers("Details").Activate

Set Shape = ActivePage.ActiveLayer.FindShape("Logo")

If Not Shape Is Nothing Then

MsgBox "Logo found"

Shape.CreateSelection

Shape.Delete

ActivePage.ActiveLayer.CreateRectangle 325, 240, 150, 40

Else

MsgBox "Logo Not Found"

End If

End With

I have attempted to use the set position and set size commands but I get an error advising the reference object no longer exists. In attempt to fix this I added to the macro create selection to select the newly created rectangle (even though this is still selected in Corel Draw at the end of the macro). This second create selection does not prevent the reference object error.

Dim Software

Dim ActivePage

Dim Page

Dim Layer

Dim Shape

Set Software = CreateObject(CorelDraw)

With Software.OpenDocument(FileName)

.Activate

.Unit = cdrMillimeter

.ReferencePoint = cdrCenter

Set ActivePage = .Pages.First

ActivePage.Layers("Details").Activate

Set Shape = ActivePage.ActiveLayer.FindShape("Logo")

If Not Shape Is Nothing Then

MsgBox "Logo found"

Shape.CreateSelection

Shape.Delete

ActivePage.ActiveLayer.CreateRectangle 325, 240, 150, 40

Set Shape = ActivePage.ActiveLayer.FindShape("Rectangle")

Shape.CreateSelection

Shape.SetPosition 325, 240

Shape.SetSize 150, 40

Else

MsgBox "Logo Not Found"

End If

End With