Results 1 to 6 of 6

Thread: Powerpoint Automation using macro's in VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    3

    Powerpoint Automation using macro's in VB

    My final year project, is to create a "Project Mgmt Review" automation tool. Every month, the company I am working for asseses it's monthly performance's in the form of 14 spread sheets which it in turn incorporates into a 20 slide powerpoint. So at the end of every month, the values in the excel spreadsheet changes,which in turn has to be incorporated into the powerpoint PMR. Until I create, this software, At the end of every month , someone will have to manually cut,copy , paste and replace the old excel sheets in the PMR, with the new one. My project is to automate this entire process, with the click of a button.
    I would have to generate a mechanism,whereby I can access the Excel spreadsheets using vb, an incorporate them into powerpoint.
    I have been using macro's succesfully , in all my test sheets. But, there is a small problem, when I update the sheet and call the macro again, The size of the worksheet either shrinks dramatically, or it suddenly become's enlargened.Does anyone know why?
    Another query of mine, is that I am not very certain as to how, the end user i.e the company I am doing my project with, will utilize this software. Do they have to go to a powerpoint file, with macro's enabled and then run the macro, Or Is their any mechanism whereby, I can create a separate form whereby they can use this tool like a normal Visual basic software. Please reply at the earliest.
    Thank you.

  2. #2
    Member
    Join Date
    Dec 2004
    Posts
    39

    Re: Powerpoint Automation using macro's in VB

    May be you can make a connection to the excel path. After that open it for export to the powerpont.
    Something sound like this:

    Dim objExcel As Object
    Set objExcel = CreateObject ("Excel.Application")
    objExcel.DisplayAlert = False 'so wont prompt out ask user whether want to disabled or enable the macro hide in the excel workbook...

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    3

    Re: Powerpoint Automation using macro's in VB

    Thank you , For that. But now, quite expectedly there, has been a modifcation.
    The requirement now, is that I have to copy a certain column of an excel spreadsheet into the powerpoint, if and only the certain column has the value "open", ie It has a condition clause. This obviously means, I can no longer use macros, atleast for this part of the project.
    I have to update a table which has 4 columns in my powerpoint, from the corresponding 4 columns in a spreadsheet has around 8 columns in the network.
    Moreover, I have to update only those entities, which have their field titled as "open", in the spreadsheet.
    From, What I understand (which is very little), I probably have to use API'S, or some other sort of mechanism to access this information, and thereby automate the whole process , which is the end goal. Please reply A.S.A.P.
    Thank you, Very much. Cheers

  4. #4
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Powerpoint Automation using macro's in VB

    same as laisengchew posted, make an object to excel to grab the data. You can move and grab rows or just cells from the spreadsheets and loop through as many spreadsheets as you have.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2005
    Posts
    3

    Re: Powerpoint Automation using macro's in VB

    Hey guys, Thank you very much for yr help so far.
    I am doing the updating, using the macro's It generate's a code, with which the project run's error free, according to requirements.
    But, The end user would have to open, the powerpoint document , enable macro's and only then run the software, which does'nt really give a professional feel to the software. After doing some reasearch, on MSDN, I came across a method whereby, I can make the automated macro code, work perfectly on a vb platform, If I modify it using the binding process, Apparently there is something called, "Early binding", "Late Binding", etc...which I will have to implement. I was wondering, If you knew anything about it, cause it is a little ambiguous in MSDN, I am pasting the sample code here, If you can give me the modified code using the binding process, I will be very obliged. Thank you very much.

    VB Code:
    1. ActiveWindow.View.GotoSlide
    2. Index:=ActivePresentation.Slides.Add(Index:=1,
    3. Layout:=ppLayoutBlank).SlideIndex
    4.   ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(Left:=120#,
    5. Top:=110#, Width:=480#, Height:=320#, FileName:="C:\Sudhir\Test\test1.xls",
    6. Link:=msoFalse).Select
    7.   With ActiveWindow.Selection.ShapeRange
    8.       .Left = 239.5
    9.       .Top = 256.875
    10.       .Width = 240.875
    11.       .Height = 26.25
    12.   End With
    13.   ActiveWindow.Selection.Unselect
    14.   ActiveWindow.View.GotoSlide
    15. Index:=ActivePresentation.Slides.Add(Index:=2,
    16. Layout:=ppLayoutBlank).SlideIndex
    17.   ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject(Left:=120#,
    18. Top:=110#, Width:=480#, Height:=320#, FileName:="C:\Sudhir\Test\test2.xls",
    19. Link:=msoFalse).Select
    20.   With ActiveWindow.Selection.ShapeRange
    21.       .Left = 263.625
    22.       .Top = 263.25
    23.       .Width = 192.75
    24.       .Height = 13.5
    25.   End With
    26.   ActiveWindow.Selection.Unselect
    27. End Sub

    Thank you.
    Last edited by RobDog888; Mar 22nd, 2005 at 12:56 AM. Reason: Added vbcode tags to format the code

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Powerpoint Automation using macro's in VB

    Which binding do you want? Here are a couple of examples of binding.
    VB Code:
    1. 'Early Binding:
    2. 'Add a reference to MS Powerpoint xx.0 Object Library
    3. 'Includes Intellisense for you objects properties and methods, etc.
    4. Private Sub Command1_Click()
    5.     Dim oApp As Powerpoint.Application
    6.     Set oApp = New Powerpoint.Application
    7.     oApp.Visible = True
    8.     'Blah, Blah, Blah...
    9. End Sub
    10.  
    11.  
    12. 'Late Binding:
    13. 'No reference added
    14. 'No Intellisense for object's properties or methods, etc.
    15. Private Sub Command1_Click()
    16.     Dim oApp As Object
    17.     Set oApp = New Powerpoint.Application
    18.     oApp.Visible = True
    19.     'Blah, Blah, Blah...
    20. End Sub
    Now with both you will need to have PowerPoint installed or you will generate an error.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width