+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
Scripts Thread, Manipulating Office (Word/PowerPoint) via PowerShell in Coding and Web Development; Originally Posted by LosOjos ...I posted how to do that waaay back just remove the $MSPPT.Visible line entirely and tag ...
  1. #16


    Join Date
    Jan 2012
    Posts
    2,676
    Thank Post
    952
    Thanked 355 Times in 270 Posts
    Rep Power
    213
    Quote Originally Posted by LosOjos View Post
    ...I posted how to do that waaay back just remove the $MSPPT.Visible line entirely and tag another $False on the end of the Open line, it works, honest!
    Yeah, that works, but since there's no program 'running', There's no ActivePresentation, so nothing can save. It throws "You cannot call a method on a null-valued expression"

    Quote Originally Posted by ascott2 View Post
    Try
    $MSPPT.ActivePresentation.Close()
    $MSPPT.Quit()

    Both are methods, without the parenthesis, you are just outputting details of the method.
    Ah, I thought the parenthesis was just providing extra information (in the case of my earlier Word script, to not save changes to the file)

    Interestingly ActivePresentation.Close() works, and ends up with PowerPoint having no file open. Quit() however, seems to do nothing. The program doesn't exit.

  2. #17

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,483
    Thank Post
    1,444
    Thanked 1,179 Times in 806 Posts
    Rep Power
    708
    Quote Originally Posted by Garacesh View Post
    Yeah, that works, but since there's no program 'running', There's no ActivePresentation, so nothing can save. It throws "You cannot call a method on a null-valued expression"
    You can get a reference to the presentation from Open, like so:

    Code:
    $PRES = $MSPPT.presentations.open("C:\test.pptx", 2, $True, $False)
    Then, replace any instance of $MSPPT.ActivePresentation with $PRES

    The post I made earlier shows what I mean, I did things a bit differently to you but it'll explain better than I can what I'm on about: Earlier Post

    EDIT: re-reading my posts, I apologise if I'm coming across as a bit of a d**k, my people skills are somewhat lacking...
    Last edited by LosOjos; 3rd June 2014 at 02:17 PM.

  3. #18


    Join Date
    Jan 2012
    Posts
    2,676
    Thank Post
    952
    Thanked 355 Times in 270 Posts
    Rep Power
    213
    Quote Originally Posted by LosOjos View Post
    EDIT: re-reading my posts, I apologise if I'm coming across as a bit of a d**k, my people skills are somewhat lacking...
    You weren't - don't worry about it.
    The reason I didn't go with that was because there was "no reason to", per-se. I see tutorials online that do a lot of things like $Var = BlahBlahBlah and then only call $Var once.. I think "Why? You're just adding a pointless, extra step!".. I didn't realise there was actually a point to yours.

  4. #19

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,483
    Thank Post
    1,444
    Thanked 1,179 Times in 806 Posts
    Rep Power
    708
    Quote Originally Posted by Garacesh View Post
    You weren't - don't worry about it.
    The reason I didn't go with that was because there was "no reason to", per-se. I see tutorials online that do a lot of things like $Var = BlahBlahBlah and then only call $Var once.. I think "Why? You're just adding a pointless, extra step!".. I didn't realise there was actually a point to yours.
    It's a habit I've picked up over the years of scripting with Office as I used to get random issues occurring using "Active..." identifiers, particularly with worksheets where the user would click on a different sheet and the macro would go haywire on it... I always learn the hard way lol! So now I make a point of storing a reference to the doc/sheet I'm working with to avoid any issues

  5. #20


    Join Date
    Jan 2012
    Posts
    2,676
    Thank Post
    952
    Thanked 355 Times in 270 Posts
    Rep Power
    213
    I guess there's always the point of "All references you might want to change are stored in variables. The variables are set at the very top of the script so it's very easy to change", too.. It's just.. Messy, I feel.

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. [MS Office - 2007] MAC Document saved as .doc but won't open in MS Office Word
    By speckytecky in forum Office Software
    Replies: 0
    Last Post: 28th February 2011, 11:09 AM
  2. [MS Office - 2010] Fonts crashing Word/PowerPoint/Publisher
    By jlucas in forum Office Software
    Replies: 1
    Last Post: 1st February 2011, 11:28 AM
  3. Deploying Open Office 3.2 via GPO Update 1
    By networkingNut in forum Windows Server 2000/2003
    Replies: 1
    Last Post: 6th May 2010, 05:46 PM
  4. Open Office & Word
    By Domino in forum Office Software
    Replies: 13
    Last Post: 11th February 2008, 01:14 PM
  5. Office Word 2007
    By wesleyw in forum How do you do....it?
    Replies: 1
    Last Post: 6th July 2007, 06:49 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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