Resize Table Pasted From Excel,

  • Hi,


    after reading several threads and posts from Andy Pope, I managed to build a macro that modifies my table in Excel as I intended and then copies it into a defined slide of a specific ppt. So far I am happy.


    On that slide is already a empty textbox. I now want to align the table's upper left corner with that of the textbox and then - with aspect ratio locked - make the table the same width as the text box.


    I recorded a macro in ppt that does exactly that. I then copy/pasted the code into my Excel macro, but it doesn't work there anymore.


    This is the code of the combined macro:



    Can anyone help? Has ppt a different macro language than Excel? Where did I do a mistake?


    Thanks.

  • Re: Resize Table Pasted From Excel,


    What exactly does "but it doesn't work there anymore" mean?
    Do you get errors, if so what.
    Do it move you shape but to the wrong place?


    At a guess I would think the explcit shape names may cause a problem.
    Whilst the textbox may remain constant the pasted picture, which is currently 'Picture 8', is likely to change.

    [h4]Cheers
    Andy
    [/h4]

  • Re: Resize Table Pasted From Excel,


    Andy,


    'It doesn't work there anymore' means, after the table being pasted on the correct slide, nothing else happens. It gets not moved and not resized and I don't get a error message.


    I post here again the code that doesn't work:



    If it was only the 'Picture 8' name that causes the problem, then the table should at least be shrunk by 0.65x, which are the first three lines of the code, and there is no 'Picture 8' mentioned yet. But even that does not happen.

  • Re: Resize Table Pasted From Excel,


    I found that someone else had a similar problem, that the name of the picture given to it by ppt changed, but it was solved using this code:


    Code
    ActiveWindow.Selection.SlideRange.Shapes(ActiveWindow.Selection.SlideRange.Shapes.Count).Select


    I copy/pasted this code into my macro but after the table being inserted as a picture nothing more happens. I don't know where my mistake is and any more help from one of you guys would be very much appreciated. Thanks.


    Chris

  • Re: Resize Table Pasted From Excel,


    You need to include the objPPT object when referencing the ActiveWindow, as you do at the begining of the code, otherwise the ActiveWindow will be Excels not PP.

    [h4]Cheers
    Andy
    [/h4]

  • Re: Resize Table Pasted From Excel,


    One more question,


    The data in the table in my excel sheet is derieved from another excel file which will have different names. Currently I update the table by clicking Edit/Links/Change Source and then choose the correct file.


    Can I put these steps into a macro too, so that when I run the macro it first opens the window where I choose the correct file and when I have done that and press OK all the other steps are executed?


    Thanks for your efforts.


    Chris

  • Re: Resize Table Pasted From Excel,


    If i change the source it records the following:


    Code
    ChDir "T:\DEALS\M\XXX\Financial model"
        ActiveWorkbook.ChangeLink Name:= _
            "T:\DEALS\S\AAA\Financial models\Project AAA Model.xls" _
            , NewName:= _
            "T:\DEALS\M\XXX\Financial model\XXX Base Case 20061208.xls" _
            , Type:=xlExcelLinks


    It autumatically updates the table with the values from the specified file. However, since the file name will always change, I would like it just to open the window where I can then choose from which file to update.


    is that possible?

  • Re: Resize Table Pasted From Excel,


    Andy,


    I tried the 'Application.GetSaveAs method', but either I did not understand what you want me to do or I did not explain what I would like to achieve.


    I want a macro or the code that opens the Edit/Links window. Then the user chooses the new file the workbook shall from now on be linked to, and after pressing 'OK' the links/values in the workbook are all updated and my other macro executed.


    So, I have a working macro that does a specific action. But every time I open the workbook I first have to change the links via Edit/Links, and then run the macro.


    I thought there might be a code that I can paste at the beginning of my macro that opens the Edit/Links dialog and after choosing, pressing ok and updating continues to execute my other macro.


    I tried the GetSaveAs method but it opens the wrong dialog. Maybe something like:


    But that doesn't work.


    Sorry if all that sounds confusing or silly, but your help is very appreciated.


    Chris

  • Re: Resize Table Pasted From Excel,


    I amended the code as follows:


    Code
    Dim Which_financial_model_contains_the_data As String
        ActiveWorkbook.ChangeLink Name:= _
            "T:\folder\filename.xls" _
            , NewName:= _
            "Which_financial_model_contains_the_data" _
            , Type:=xlExcelLinks


    Heyyy, and now it works exactly as I want it to do.


    Thanks to everybody who helped me!!


    Chris

  • Re: Resize Table Pasted From Excel,


    This is my unique solution to Paste and Centralize the chart images:


    ' ScaleProportionally Method
    ' Align pasted chart
    objApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
    objApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
    End Sub

    André Luiz Bernardes
    A&A® - Work smart, not hard.
    "[email protected]"[/email]

    Blogs: Office| Excel | Access |
    [Blocked Image: http://al-bernardes.sites.uol.com.br/Photos/InAnyPlace03.gif]

  • Re: Resize Table Pasted From Excel,


    Bernardes,

    Welcome to Ozgrid and thank you for posting an alternative solution in this thread. However in future please ensure that all VBA is wrapped in [noparse]

    Code

    [/noparse] tags.

    Thank you.

    Also I would recommend that you remove your email from the posted code. Public forums like Ozgrid are regularly harvested for email addresses by bots and you are likely to become the target to a great deal of spam if your email address remains.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!