VBA: Manipulate data in open Excel Workbook from PowerPoint-VBForums
Results 1 to 5 of 5

Thread: VBA: Manipulate data in open Excel Workbook from PowerPoint

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    3

    Resolved VBA: Manipulate data in open Excel Workbook from PowerPoint

    Hi,

    I have a - hopefully - easy question:

    How do I address an open Excel Workbook from PowerPoint in order to change a value?

    I am currently doing something like this:

    Code:
    Dim wb As Excel.Workbook
    Dim ws As Excel.Worksheet
    
    Set wb = Workbooks.Open("D:\Documents and Settings\...\TEST.xls")
    'THIS is where I get problems. I do not want to OPEN the workbook since it is already open...
    
    Set ws = wb.Worksheets("Menu")
    
    ws.Range("targetcell") = 0 'do something in the worksheet...
    Does anybody have an idea, how I can address and manipulate data in an existing, open workbook?

    Cheers,

    Marc
    Last edited by Marc80; Mar 31st, 2010 at 07:44 AM. Reason: Problem resolved

  2. #2
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,928

    Re: VBA: Manipulate data in open Excel Workbook from PowerPoint

    Welcome to the forums

    Would you be having the name of the open workbook?
    The poster formerly known as koolsid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    3

    Re: VBA: Manipulate data in open Excel Workbook from PowerPoint

    Thanks

    Yes, I have the name and the full path of the Excel file (both constant).

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    20,021

    Re: VBA: Manipulate data in open Excel Workbook from PowerPoint

    Set wb = Workbooks.Open("D:\Documents and Settings\...\TEST.xls")
    change to
    Set wb = getobject("D:\Documents and Settings\...\TEST.xls")
    will error if not already open
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2010
    Posts
    3

    Re: VBA: Manipulate data in open Excel Workbook from PowerPoint

    westconn1, thanks a lot! Works perfectly

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.