Consulting

Results 1 to 7 of 7

Thread: Load Excel Userform from Powerpoint Button

  1. #1
    VBAX Contributor
    Joined
    Nov 2007
    Posts
    144
    Location

    Load Excel Userform from Powerpoint Button

    Morning everyone,

    I'm having one of those Mondays and drawing a real blank even though I know it is really simple.

    Also, apologies if this is in the wrong section - Powerpoint / Excel????

    I have a userform in a worksheet - C:\test\test.xls

    I have a powerpoint presentation (powerpoint.ppt) in the same folder with a command button on slide1

    Can anyone think of the code to call the userform from the closed workbook after clicking the powerpoint command button.

    I just want it to load the form and show it on screen.

    I know Userform1.show goes somewhere in there but lost after that.

    Any help appreciated

    F

  2. #2
    Hi there,

    I just wanted to know, why don't you put the form on the .ppt file? I think it would be much easier. The button code should be simple then:
    [VBA]Private Sub CommandButton_Click()
    frmName.Show
    End Sub[/VBA]

  3. #3
    VBAX Contributor
    Joined
    Nov 2007
    Posts
    144
    Location
    Quote Originally Posted by kakaruzas
    Hi there,

    I just wanted to know, why don't you put the form on the .ppt file? I think it would be much easier. The button code should be simple then:
    [vba]Private Sub CommandButton_Click()
    frmName.Show
    End Sub[/vba]
    The form is linked directly to some data in the excel workbook and is not a standalone form.

    I'm doing a presentation and just want to press a button on a slide and have the form pop up to demonstrate what it looks like then I can close it and carry on.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You will need a procedure called ShowForm in the workbook that does a simple

    [vba]

    FormName.Show
    [/vba]

    and then use

    [vba]

    Public Sub DoExcel()
    Dim XLApp As Object
    Dim XLWB As Object

    Set XLApp = CreateObject("Excel.Application")
    XLApp.Visible = False
    Set XLWB = XLApp.workbooks.Open("C:\test\Book With Form.xls")
    XLApp.Windows(XLWB.Name).Visible = False
    XLApp.Run "'" & XLWB.Name & "'!ShowForm"

    XLWB.Close SaveChanges:=False
    Set XLWB = Nothing
    XLApp.Quit
    Set XLApp = Nothing
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Contributor
    Joined
    Nov 2007
    Posts
    144
    Location
    Thanks Bob,

    I'm getting a 'Server threw up exception' automation error and 'Object Required' at this line:

    [vba]XLWB.Close SaveChanges:=False[/vba]

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Does your form do anything nasty?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Contributor
    Joined
    Nov 2007
    Posts
    144
    Location
    Not that I am aware of

    I have been playing around with it but still getting the error.

    I think this is how the process should go:

    1. Press command button in powerpoint

    2. Code should only open the spreadsheet - no need to tell it to show userform and the excel spreadsheet does this automatically

    3. Press the close spreadsheet button on the userform and excel closes.

    4. Return to Powerpoint

Posting Permissions

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