Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Setting GUID reference error

Hi,

I have the following queries with reference to the code modules below :

1) If I first run SetMyRef and then run ExcelChartsToPPT, it works fine. But
if I *call* SetMyRef from the second module the reference to Powerpoint is
not set, and the code aborts. Why is this so ?
2) How should I change my code to late binding for ExcelChartsToPPT ?

Option Explicit

Sub SetMyRef()
Dim R As Variant

For Each R In ActiveWorkbook.VBProject.References
If R.GUID = "{91493440-5A91-11CF-8700-00AA0060263B}" Then
Exit Sub
End If
Next

On Error GoTo NotFound

ActiveWorkbook.VBProject.References.AddFromGuid
"{91493440-5A91-11CF-8700-00AA0060263B}", _
Major:=2, Minor:=7

Exit Sub

NotFound:
MsgBox "CAN'T RUN THIS CODE"

End Sub

Sub ExcelChartsToPPT()

On Error GoTo ErrHandler

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim SlideCount As Long
Dim iCht As Integer
Dim i As Integer
Dim Ans As String


Ans = MsgBox("Copy all charts in workbook to Powerpoint ?", vbYesNo +
vbQuestion, "Confirm")
If Ans = vbYes Then GoTo Proceed Else Exit Sub

Proceed:
Set PPApp = CreateObject("Powerpoint.Application")
PPApp.Visible = True
PPApp.WindowState = ppWindowMinimized

' Create active presentation
Set PPPres = PPApp.Presentations.Add
PPPres.Slides.Add 1, ppLayoutTitle

For i = 1 To Worksheets.Count 'All worksheets with embedded charts
needing transfer to PP
For iCht = 1 To Worksheets(i).ChartObjects.Count
' copy chart as a picture
Worksheets(i).ChartObjects(iCht).Chart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
'xlBitmap can also be used

' Add a new slide and paste in the chart
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select
' align the chart
PPApp.ActiveWindow.Selection.ShapeRange.Align
msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align
msoAlignMiddles, True

End With

Next iCht
Next i

PPPres.Slides(1).Select
PPApp.WindowState = ppWindowMaximized

' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing

Exit Sub

ErrHandler: MsgBox "An error occurred; please re-try !", vbInformation

End Sub


Thanks,
Amit


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create A GUID Derek Hart Excel Worksheet Functions 3 December 24th 07 01:30 AM
.dll and GUID Ross[_7_] Excel Programming 0 May 12th 04 03:56 PM
How retrieve GUID and Document Properties Bob Phillips[_6_] Excel Programming 1 May 5th 04 04:56 PM
How retrieve GUID and Document Properties pikus Excel Programming 0 May 5th 04 04:13 PM
Possible to generate a GUID in Excel? Dan[_29_] Excel Programming 2 January 6th 04 06:30 AM


All times are GMT +1. The time now is 09:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"