Consulting

Results 1 to 6 of 6

Thread: open a specific excel worksheet from powerpoint

  1. #1
    VBAX Regular
    Joined
    Feb 2018
    Posts
    10
    Location

    open a specific excel worksheet from powerpoint

    Hi,
    I want open a specific excel worksheet from powerpoint.
    I try:
    Sub ApriExcel()
    Dim xlApp As Object
    Dim xlWorkBook As Object
    Dim ExcelValue As Double
    
    Set xlApp = CreateObject("Excel.Application")
    
    xlApp.Visible = True
    Set xlWorkBook = xlApp.Workbooks.Open("C:\Users\Microsoft\Desktop\Formazione light\Formazione\Start formazione\Slides Ended\AvvioCorso.xlsm", True, False)
    
    xlWorkBook.Worksheets("Start").Range("B2").Value 'give me a debug Error
    
    End Sub
    But debug does not like it . Where am I wrong?

    Thanks in advance
    bg66

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    It should not give a debug error. If there are problems with the path you may get a runtime error. Have you a screen shot of the error. Is Option Explicit ON?

    I doubt whether ExcelValue is a Double but it should work.

    Are you intentionally setting UpdateLinks to True ?
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Regular
    Joined
    Feb 2018
    Posts
    10
    Location
    Hello John,

    Quote Originally Posted by John Wilson View Post
    It should not give a debug error. If there are problems with the path you may get a runtime error. Have you a screen shot of the error. Is Option Explicit ON?






    Quote Originally Posted by John Wilson View Post
    I doubt whether ExcelValue is a Double but it should work.

    Are you intentionally setting UpdateLinks to True ?
    No, sorry.I tried, badly, to change your macro posted in another thread.

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Don't know then. If you have been playing with code that opens Excel it might be worth checking you don't have an invisible copy open.

    CTRL+SHIFT+ESC to open Task Manager. Choose processes and look for EXCEL.exe running in the background. If it's there are you don't have Excel open normally then End the process and try again.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Regular
    Joined
    Feb 2018
    Posts
    10
    Location
    But is this script string,anyway,correct?
    xlWorkBook.Worksheets("Start").Range("B2").Value
    In Excel VBA the correct phrase is: ".Range("B2").Select".

    Thanks for your answer.

  6. #6
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    Depends what you are trying to do - as written you are correct it is incorrect

    If you want to read the value in the cell

    Excelvalue=xlWorkBook.Worksheets("Start").Range("B2").Value

    is correct

    If you want to select that cell then as you say ...
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

Posting Permissions

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