-
Hello Jon,
I do have the Excel Object Library referenced in PowerPoint and moved the MsgBox statement to the end of the code as you suggested. (Please see below). Unfortunately, I am still getting the same error "Run-time error 91 Object variable or With block variable not set."
The code runs just fine the first time. When I run the same code again, Excel does not close and get the error above.
When clicking Debug, ActiveWorkbook.Save is highlighted in yellow. This might seem like trivial code but it is "proof of concept" for a much larger project. I have a team of co-workers who have a map of the warehouse where rooms are manually color coded based on values from Excel. I want to get this code working first before I create the code for the dozens of rooms on the PowerPoint map.
Any ideas why the code works just fine upon first execution but fails to close Excel and generates the error above on the second execution? Thanks
Private Sub RetrieveExcelValue()
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("E:\Special Projects\PPT Project for Matthew Orenchuk\Cross Flow Skid EER.XLSM", True, False)
ExcelValue = xlWorkBook.Worksheets("PPT Transfer").Range("C5").Value
ActiveWorkbook.Save
xlApp.Quit
MsgBox ("The value of this range in Excel is " & ExcelValue)
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules