View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown[_5_] Gary Brown[_5_] is offline
external usenet poster
 
Posts: 236
Default external link to start excel form

Using Automation, you could....

1) Make sure that there is a macro in the Excel workbook
that opens the form.
Example:
Public Sub OpenTheForm()
ufTest.Show
End Sub
- where 'OpenTheForm' is the macro
- where 'ufTest' is the name of the form

2) In PowerPoint, create a Command Button on your slide by...
- opening up the 'Control Toolbox' commandbar
- select the 'Command Button'
- draw the button at the bottom of the slide

3) Right Click on the Command Button and go to 'Properties'

4) Change the Caption to something like 'Open Excel Form'

5) x out of the Properties window

6) Double-click on the Command Button and the
Visual Basic Editor will appear

7) You will see something like...
Private Sub CommandButton1_Click()

End Sub

8)
- where strMacro is the macro in Excel
that opens the form
- where strWorkbook is the workbook that
contains the form
Replace that code with...

'/--- S T A R T -- O F -- M A C R O --------------/
Private Sub CommandButton1_Click()
Dim appExcel As Object
Dim strWorkbook As String
Dim strMacro As String
Dim x As Variant

On Error GoTo err_Sub

'- - - - V A R I A B L E S - - - - - -
strWorkbook = "C:\Temp\Book1.xls"
strMacro = "OpenTheForm"
'- - - - V A R I A B L E S - - - - - -

'open a new instance of Microsoft Excel (late binding)
Set appExcel = CreateObject("Excel.Application")
appExcel.Application.Visible = True

'Open a workbook
appExcel.Application.Workbooks.Open strWorkbook

'run the macro in Excel that opens the form
x = appExcel.Application.Run(strMacro)

'close the workbook with the form without saving
appExcel.ActiveWorkbook.Close SaveChanges:=False

'get out of Excel
appExcel.Quit

exit_Sub:
On Error Resume Next
Set appExcel = Nothing
Exit Sub

err_Sub:
Debug.Print "Error: " & Err.Number & " - (" & _
Err.Description & ") - " & Now()
GoTo exit_Sub

End Sub
'/--- E N D -- O F -- M A C R O --------------/

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"lorraine" wrote:

Through a lot of trial and error, I finally got an excel form to run (I'm new
to this). I'd like to start the form from within a powerpoint presentation.
I can link to the macro in excel to start the form but then have to run the
macro. I'd like to be able to just click on something from powerpoint that
will make the excel form pop up (automatically run the macro). Is there some
code that I can copy or is there another way of getting this to work?

Thank you in advance for your help.
Lorraine