Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-24-2014, 07:28 AM
SeattleITguy SeattleITguy is offline Calling a macro in powerpoint from command line Windows Vista Calling a macro in powerpoint from command line Office 2010 32bit
Novice
Calling a macro in powerpoint from command line
 
Join Date: Nov 2014
Posts: 7
SeattleITguy is on a distinguished road
Default Calling a macro in powerpoint from command line

Greetings everyone

I am trying to call a macro in PowerPoint from the command line to simplify things for my team at work.

Trying to keep it simple this is the code I am working with so far:

Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Run "Presentation.pptm!UpdateLinks2Local"

I get the following error:

Row 2
Character 1
Error: Application.Run : Invalid Request. Sub or function not defined.
Code 80048240



I'm running this on Windows Vista Enterprise with Office 2010 standard 32-bit

I wouldn't know what function or sub to put there.

Please let me know if I can explain anything further.

Thanks in advance!
Reply With Quote
  #2  
Old 11-24-2014, 08:16 AM
JohnWilson JohnWilson is offline Calling a macro in powerpoint from command line Windows 7 64bit Calling a macro in powerpoint from command line Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Presuming Presentation.pptm is open and the sub exists that depending on what you mean by command line that should work.

It's probably not the way to do it though. Why not create a ppam AddIn that creates a ribbon button to run the code on any active presentation?
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 11-24-2014, 08:30 AM
SeattleITguy SeattleITguy is offline Calling a macro in powerpoint from command line Windows Vista Calling a macro in powerpoint from command line Office 2010 32bit
Novice
Calling a macro in powerpoint from command line
 
Join Date: Nov 2014
Posts: 7
SeattleITguy is on a distinguished road
Default

Quote:
Originally Posted by JohnWilson View Post
Presuming Presentation.pptm is open and the sub exists that depending on what you mean by command line that should work.

It's probably not the way to do it though. Why not create a ppam AddIn that creates a ribbon button to run the code on any active presentation?
Thank you for your response.

My apologies I should have clarified that it I don't want the file to open. It would be nice to have it run in the background somehow because when the file opens it prompts the user to update the links or not before the macro runs. For Excel an example is:

objExcel.Application.Run "Presentation.pptm!UpdateLinks2Local"

I would like that (above) functionality but for PowerPoint.

My main goal is that a user can run this unattended, as it takes 3-5 minutes to update everything. The intention to be able to run the script to update the PPT just before a presentation to a client.
Reply With Quote
  #4  
Old 11-24-2014, 09:30 AM
JohnWilson JohnWilson is offline Calling a macro in powerpoint from command line Windows 7 64bit Calling a macro in powerpoint from command line Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

I don't think the code will run in PPT if it is cl;osed.

You may be able to open the presentation in code and NOT trigger the usual link update

Sub fixme()
Dim thisPres As Presentation
Set thisPres = Presentations.Open("C:\Users\John\Documents\Presen tation1.pptm", WithWindow:=False)
With thisPres
'do whatever
End With
End Sub
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #5  
Old 11-26-2014, 01:41 AM
SeattleITguy SeattleITguy is offline Calling a macro in powerpoint from command line Windows Vista Calling a macro in powerpoint from command line Office 2010 32bit
Novice
Calling a macro in powerpoint from command line
 
Join Date: Nov 2014
Posts: 7
SeattleITguy is on a distinguished road
Talking Solved

I found a working solution of calling a macro from VBScript.

Here is the code that does what I need. Which is to open the PPT file and perform the macro. I don't get prompted to update links.

Unfortunately PPT must open to perform the macro but I'll just have the macro close PPT once it's finished or have it call on another macro to close it.

Code:
Set oApp = CreateObject("Powerpoint.Application")
Set oPres = oApp.Presentations.Open("D:\Users\JustinBryant\Project_Organigram_24.11.14.pptm")
Set oSlide = oPres.Slides(1).Duplicate
oApp.Run "UpdateLinks2Local"
The code would only work with the 3rd line that duplicates the slide but it all functions well. The link below discusses further on this strange anomaly.

I am open to any suggestions or ideas if anyone has any.

http://help.lockergnome.com/office/c...ict469171.html


Thank you for your responses JohnWilson!
Reply With Quote
Reply

Tags
command, external, macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
From the command line, how do I run a Word macro? jdockstader Word 7 02-04-2013 06:09 AM
Calling a macro in powerpoint from command line Command line syntax for 2010 asearle Word 1 08-07-2012 05:42 AM
Invoking a command line from inside Word bolpom Word 1 03-16-2011 03:03 AM
Command Line Argument xJediDadx Outlook 1 02-21-2011 03:47 PM
Command Line Switches Ringmaster Office 0 08-10-2010 06:27 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft