Results 1 to 11 of 11
  1. #1
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    import and export freeform as XY in PPT ( PPT 2002 SP-2)

    In PPT, I would like to import a freeform from a tabulated ASCII file. Example XY coordinates and ASCII file format:

    479913.344 7647915.000999999999999 7 1
    480081.844 7648068.000999999999999 7 1
    480273.313 7648175.500999999999999 7 1
    480510.719 7648336.000999999999999 7 1
    480112.469 7648305.500999999999999 7 1
    479691.219 7647769.500999999999999 7 1


    I also want to export or write the freeform into the same format. So that if I modify the shape, I can save it and export it.

    I figured out how to create the freeform (re-scaling and shifting in XY to plot it in the work area), playing with WordPad, Excel, and PPT.

    But I need help with the commands to read from an ASCII file, write to an ASCII file, and getting the XY coordinates for each of the vertices.

    Can anyone help?

    Thank you.
    Guillermo

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: import and export freeform as XY in PPT ( PPT

    You have at least two options for reading tab-delimited data from a text file: VB's built-in file I/O commands, and the Scripting Library's FileSystemObject and TextStream objects. You can find examples of both here in the Lounge.

    Once you have your text file open, you can read in a line at a time of text into a variable. However, you can make your life easier by reading it into a dynamic array. I think the array typically is of a string type, but that's okay, you can convert the data as needed once you have it stored. So, for example, hacked together from memory:

    dim strArray() as String
    ... 'here you're in a loop, until oStream EOF
    strArray = Split(oStream.ReadLine, vbTab)
    ... 'interate over your array to use the data and then loop

    Does this help?

  3. #3
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: import and export freeform as XY in PPT ( PPT

    this is great help! <img src=/S/blackteeth.gif border=0 alt=blackteeth width=20 height=20>

    I'll have to experiment with the code, and re-write my routines.

    in PPT 2002, how do I get the XY coordinates of each vertice of the freeform, so I can export to a new ASCII in case I edit my freeforms? something like...

    width selection.shape
    width shape
    for each vertice ...........?

    Thank you
    Guillermo

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: import and export freeform as XY in PPT ( PPT

    <P ID="edit" class=small>(Edited by jscher2000 on 06-Aug-04 16:47. Replaced picture.)</P>Okay, first I had to figure out what a free form is. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> As you can see, I'm not a good artist. One hand-drawn semi-rectangle has a collection of 27 Nodes or 28 Vertices. It looks as though the Vertices collection is easier to work with if you don't need the other information available in the Nodes collection.

    The values in these collections are in points (72 per inch), measured from 0,0 at the upper left of the slide. I'm not sure how that compares with the data you listed in your first post; those numbers are much, much larger. Are they in "twips" (units of screen display, something like 1440 to an inch)?

    I suggest you use a counter and a For loop from 1 to the size of the Vertices collection, and write out the two number with a tab in between. I don't know what the other data elements in your data represent, but maybe this is enough to get you to the next step?

    As for the mechanics of identifying a particular shape on a slide, the first couple of shapes on a slide usually are placeholders for text (defined in the Master slide). I find the concept of the selection hard to work with in PowerPoint, so even I probably would comb through the Shapes looking for a FreeForm. Hopefully the PPT code gurus will have a better solution.

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: import and export freeform as XY in PPT ( PPT

    Jefferson,

    How did you get all the properties of the object into local variables so you could view them like that?

    StuartR

  6. #6
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: import and export freeform as XY in PPT ( PPT

    The easy way would be, insert a procedure (if necessary) then set a breakpoint. Run sub. While in Break mode, view Locals Window. See attached pic. You can start at top of tree and drill down thru Application Object, ActivePresentation, Slides, Shapes, etc & view properties/values for each object in open project. NOTE: The code in this project is using an object variable (app) that references the current instance of PPT Application object. Though just about any object variable that references an object in active presentation should work, since just about every object (such as a Shape) has an Application property that returns a reference to the Application object, which you could then drill down thru in the Locals window. Of course, the object variable would have to be in scope when entering Break mode.

    HTH

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: import and export freeform as XY in PPT ( PPT

    I generally blurt out a quickie temporary procedure similar to this:

    Sub SniffShape()
    dim shp as Shape
    Set shp = ActivePresentation.slides(1).shapes(3)
    stop
    set shp = nothing
    end sub

    When the procedure stops, I open the (undocked) Locals window and inspect the properties for the shp object. Mark's approach makes more sense if you already have some real code you're working on.

  8. #8
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: import and export freeform as XY in PPT ( PPT

    Mark,

    Thanks (to you and Jefferson) for the education.

    StuartR

  9. #9
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: import and export freeform as XY in PPT ( PPT

    As a VB begginer, I am learning a lot here! <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

    I am trying to plot in power point some shapes or polygons I have in a map. The polygons have XY rectangular coordinates (Gauss Kruger). That's why the numbers are so big. They are in meters, and I am mapping features that are km in size. So I re-scaled and shifted all of the nodes to fit them in the drawing area(with excel, but formulas are very easy to include in a ppt macro).

    I see that, ppt could have a limitation from the point of view of canvas size and point location accuracy, if I wanted to edit an object and export to a map. So I've modified my project to do the following:

    What I want to do now is plot a number of shapes from an ASCII file. Select some and delete. Write to an ASCII file the remaining shapes. So my workflow would be something like this:

    1. Read an ASCII file
    2. Locate Upperleft most and Lowerright most data points to define extent of "map" and scaling parameters to make the polygons fit the drawing area, without distortion or XY apect ratio change
    3. Create the shapes reading the point data in ASCII format. The last column in my ASCII table has an ID # for each polygon. Name the shapes with that ID.
    4. In ppt drawing area , select shapes and delete the ones I don't need.
    4. Read the list of remaining shapes.
    5. Write a new ASCII file, including only the data (and shapes) that remains in the drawing area. In order not to loose the accuracy of the original XY's, I would read the original ASCII data, locate the polygons by name and ID#
    6. Write to a new ASCII, re-numbering the shapes or polygons in the new ASCII file from 1 to n.

    Next goal: to create the shapes from several ASCII files and merge them into a new , single, ASCII.

    Why not do this in excel, in a spreadsheet? I want to be able to select the shapes in the drawing area, the way you do commonly in ppt (or any other drawing application). (Suggestions about doing this in excel only? that would be great too!)

    Piece of cake! With what you have taught me, I should be able to do this right away. <img src=/S/cool.gif border=0 alt=cool width=15 height=15>
    Guillermo

  10. #10
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: import and export freeform as XY in PPT ( PPT

    Here's a random thought: what if you draw the FreeForm "off slide" and then set the position to 0,0 (as on the Position tab of the Format>AutoShape dialog), lock the aspect ratio and reset the width and height to fit within your desired dimensions (as on the Size tab of that dialog). If PPT will allow it, it seems easier than doing all the math yourself. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  11. #11
    2 Star Lounger
    Join Date
    Apr 2002
    Location
    Houston, Tx, USA
    Posts
    121
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: import and export freeform as XY in PPT ( PPT

    Because I will be importing several geographically referenced "freeforms" (polygons, > 50), I think I'd rather stick to doing the math while importing from the ASCII file. It should not be hard. Just getting X-Y min and max, slide size, setting a scaling factor, and one X-Y bulk shift for all of the polygons. I am not worried about that (I've set it up in excel already and made it work. With text concatenation in excel, I created most of the text macro that goes in ppt to create the polygons)

    My second thought was about doing this entirely with excel rather than ppt. Loading the data into a spreadsheet and using the autofilter sounds cool too. But I don't know if I would be able to select the polygons from a chart or graph, and highlight them automatically on the spreadsheet (selecting the polygons with my mouse by defining a rectangle). This part sounds to be easier in ppt than excel.
    Guillermo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •