|
-
Dec 18th, 2008, 12:06 PM
#1
Thread Starter
Member
[RESOLVED] VBA Code not working in VB6
I was building something to run an update in PPT to refresh the links. I am now having to update some related things in access along with some pivot tables in Excel. So I decided to just build it in VB6. However, my powepoint code does not work, I have added the powerpoint libraries into VB, but it fails everytime. I open the ppt but when it gets to checking the shape.type it fails....any idea?
Code:
Dim osld As Slide
Dim oshp As Shape
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.Type = msoLinkedOLEObject Then 'Fails Here on oshp.Type
oshp.LinkFormat.Update
End If
Next oshp
Next osld
EDIT:This code is straight out of PPT so the ActivePresentation thing obviously needs to be changed, I accidently deleted the updates I made in vb6
EDIT: The error it gives me is a compile error: Method or data member not found, which sounds like a reference but I cant find anymore references that I should need.
Last edited by Beall49; Dec 18th, 2008 at 12:15 PM.
-
Dec 18th, 2008, 12:17 PM
#2
Re: VBA Code not working in VB6
VBA code is not 100% compatible with VB6 and visa versa.
You did add a reference to PowerPoint so msoLinkedOLEObject is defined?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 18th, 2008, 12:29 PM
#3
Thread Starter
Member
Re: VBA Code not working in VB6
^Yes sir....MS PPT 11.0 Obj Lib
Could I be missing anything else?
This code should work.
-
Dec 18th, 2008, 12:49 PM
#4
Re: VBA Code not working in VB6
.Type isnt necessarily a property of a Shape object.
Check it out in the Object Browser and Intelisense. 
Do you have a reference to Office 11.0 too?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 18th, 2008, 01:11 PM
#5
Thread Starter
Member
Re: VBA Code not working in VB6
Ok so I noticed that I wasn't telling it what object, so I got past that, now though it fails on the first line saying the object doesnt support this property or method.
Code:
Dim oSld As Slide
Dim oShp As Shape
Set objPpt = CreateObject("PowerPoint.Application")
objPpt.Visible = True
Set objPres = objPpt.Presentations.Open("C:\Documents and Settings\u1\Desktop" _
& "\Flash Report.ppt")
For Each oSld In objPpt 'it fails on this line
For Each oShp In oSld.Shapes
If objPpt.Shape.Type = msoLinkedOLEObject Then
objPpt.oShp.LinkFormat.Update
End If
Next oShp
Next oSld
End Sub
Last edited by Beall49; Dec 18th, 2008 at 01:17 PM.
-
Dec 18th, 2008, 01:27 PM
#6
Re: VBA Code not working in VB6
Try it like this...
Code:
Option Explicit
Private Sub Form_Load()
Dim oSld As PowerPoint.Slide
Dim oShp As PowerPoint.Shape
Dim objPpt As PowerPoint.Application
Set objPpt = CreateObject("PowerPoint.Application")
objPpt.Visible = True
Set objPres = objPpt.Presentations.Open("C:\Documents and Settings\u173934\Desktop\BSA-AML Production Flash Report.ppt")
For Each oSld In objPpt.Presentations.Item(0).Slides 'it fails on this line
For Each oShp In oSld.Shapes
If oShp.Type = msoLinkedOLEObject Then
oShp.LinkFormat.Update
End If
Next oShp
Next oSld
End Sub
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 18th, 2008, 01:29 PM
#7
Thread Starter
Member
Re: VBA Code not working in VB6
^ You are a god, it worked the first time.
-
Dec 18th, 2008, 01:34 PM
#8
Re: VBA Code not working in VB6
Cool, glad its working now. 
Did you notice the changes and why?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 18th, 2008, 01:37 PM
#9
Thread Starter
Member
Re: VBA Code not working in VB6
I noticed the changes but I dont think I could explain what its really doing besides possibly finding each slide...
-
Dec 18th, 2008, 01:41 PM
#10
Re: VBA Code not working in VB6
The way you had it before was looping off of the Application object which doesnt have a Slides collection. Then the inner loop was looping off of the oShp object which was invalid because of the previous error.
So the fix was to loop using the first presentation's slides collection. Then you can access each of the shapes inside that slide in your inner loop.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
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
|
Click Here to Expand Forum to Full Width
|