Jump to content
rg20

Windows 10 / Office SaveAs

Recommended Posts

rg20

Greetings all,

 

I have an app that runs fine in windows 7 but not windows 10.

issue : when entering the filename to save, it enters it into the saveAs dialog box, but Office still tries to save as "Diagram1" or "Presentation1"

 

$FileError = ""
        MonitorProcess2("VISIO")
        _DebugOut("Visio Done")

        MonitorProcess2("POWERPNT")

        _debugOut("Powerpoint Done")



        CloseSave($FileSavePathName, $SaveAsWindow)
        _DebugOut("Saved and closed Powerpoint")

        _VSO_DocumentSave($objVisioFile)
        while not _VSO_DocumentSaved($objVisioFile)
        WEnd
        _VSO_VisioClose($objVisioFile)
        _DebugOut("Saved and closed Visio")
    else
        _DebugOut("Filename Does not exist = "& $FilePathName)
    EndIf

the monitor process2 just makes sure the processes are complete before trying to save the files.

 

The closeSave function is below, but since I am opening the file with the proper name, this is not an issue

func CloseSave($SaveFile, $SaveAsWindow)
    _DebugOut("Save File ")
    _DebugOut($SaveFile)
    send("!{F4}")
    send ("!S")
    $title = WinGetTitle("[ACTIVE]")
    _DebugOut("WINDOW - current window is Powerpoint to enter filename " & $title)
    while not ($title = $SaveAsWindow)
        $title = WinGetTitle("[ACTIVE]")
    wend
    ControlSetText ($SaveAsWindow,"","[CLASS:Edit; INSTANCE:1]",$SaveFile)
    send ("!S")
        $title = WinGetTitle("[ACTIVE]")
    while not StringInStr($title,"Visio")
        $title = WinGetTitle("[ACTIVE]")
    wend
EndFunc

 

Edited by rg20

Share this post


Link to post
Share on other sites
rg20

You are correct, I was not calling that method as I had thought. (I have updated the original post to correct that)

 

I am using the controlsend.

 

The reason I use this is because Visio lauches a powerpoint app automatically, I seem to have an issue trying to get a handle on that application 

Edited by rg20

Share this post


Link to post
Share on other sites
water

Please have a look at my PowerPoint UDF -  it allows to connect to an already running PowerPoint instance/presentation.

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
rg20

Thank you Water for your helpful advice,

 

I remvoed the closesave function and added the following

$oPPT =_PPT_Open()
      _PPT_PresentationAttach($oPPT,"partialtitle")
      _PPT_PresentationSaveAs($oPPT, "c:\a\test")
        _DebugOut("Saved and closed Powerpoint")

When I was done, I could not find a file in the directory C:\a.

I would expect to see test.ppt

 

Not sure if an object is being returned or I'm doing something wrong.

I modified the presentationAttach script to allow for partial title search as the number keeps increasing.

Func _PPT_PresentationAttach($sString, $sMode = Default)
    Local $oPresentation, $iCount = 0, $sCLSID_Presentation = "{91493444-5A91-11CF-8700-00AA0060263B}" ; Microsoft.Office.Interop.PowerPoint.PresentationClass
    If $sMode = Default Then $sMode = "FilePath"
    While True
        $oPresentation = ObjGet("", $sCLSID_Presentation, $iCount + 1)
        If @error Then Return SetError(1, @error, 0)
        Switch $sMode
            Case "filename"
                If $oPresentation.Name = $sString Then Return $oPresentation
            Case "filepath"
                If $oPresentation.FullName = $sString Then Return $oPresentation
            Case "title"
                If $oPresentation.Application.Caption = $sString Then Return $oPresentation
            Case "partialtitle"
                If StringInStr($oPresentation.Application.Caption,$sString) Then Return $oPresentation
            Case Else
                Return SetError(2, 0, 0)
        EndSwitch
        $iCount += 1
    WEnd
EndFunc   ;==>_PPT_PresentationAttach

 

Share this post


Link to post
Share on other sites
water

PresentationAttach and PresentationSaveAs require a presentation object. Hence it should be:

$oPPT =_PPT_Open()
$oPresentation = _PPT_PresentationAttach("text you are looking for in the title", "partialtitle")
_PPT_PresentationSaveAs($oPPT, $oPresentation, "c:\a\test")
_DebugOut("Saved and closed Powerpoint")

N.B: It is always a good idea to check @error after having calld a function.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
rg20

Awesome start, but missed a few things and still have one issue

 

If you open the PPT without saving it first, it seems like the environment can find it, but the attach can't attach to it

 

I created a slide deck named "hey you" in my documents folder then opened Powerpoint without saving it, so the default name was Presentation1 - Microsoft Powerpoint so my path looks like this

Row|Col 0|Col 1|Col 2
[0]||Presentation1|
[1]||hey you.pptx|C:\Users\....\Documents
 

then using this code, I put the Powerpoint.au3 in my local directory for now

 

#include "Powerpoint.au3"
#include "Visio.au3"
#include <misc.au3>
#include <File.au3>
#include <Debug.au3>

$oPPT =_PPT_Open()
$Presentations = _PPT_PresentationList($oPPT)
_ArrayDisplay($Presentations, "Sorted tree")
$oPresentation = _PPT_PresentationAttach("Presentation","title", True)
_PPT_SlideAdd($oPresentation)
_PPT_PresentationSaveAs($oPresentation, "C:\a\test" )

$oPresentation = _PPT_PresentationAttach("hey you","title", True)
_PPT_SlideAdd($oPresentation)

_PPT_PresentationSaveAs($oPresentation, "C:\a\test2" )

the attach with the "Presentation" does not get a second slide or saved

The "hey you" presentation does and is saved to the indicated pat as expected.

any thoughts?

Share this post


Link to post
Share on other sites
water

Seems to be a bug in the latest UDF version in function _PPT_SlideAdd.
Will need to rethink the function :( 
I think Alpha 3 doesn's have this bug - if needed I can post this version here or in the download Forum.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
rg20
On 6/16/2017 at 11:31 AM, water said:

 

Thanks for the update, I wasn't sure if I was going crazy.

 

I would love to have the new version for testing

Share this post


Link to post
Share on other sites
water

A newer/fixed Version (Alpha 6) isn't available yet. But I think Alpha 4 doesn's have this bug:

PowerPoint Alpha 4.zip


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
rg20

I have tried this and experienced the same bug.  I think there is an issue with the attach when the file is not saved, IE no directory listed

 

Func _PPT_PresentationAttach($sString, $sMode = Default)
    Local $oPresentation, $iCount = 0, $sCLSID_Presentation = "{91493444-5A91-11CF-8700-00AA0060263B}" ; Microsoft.Office.Interop.PowerPoint.PresentationClass
    If $sMode = Default Then $sMode = "FilePath"
    While True
        $oPresentation = ObjGet("", $sCLSID_Presentation, $iCount + 1)
        If @error Then Return SetError(1, @error, 0)  <-------------------This is the line kicking back the error message
        Switch $sMode
            Case "filename"
                If $oPresentation.Name = $sString Then Return $oPresentation
            Case "filepath"
                If $oPresentation.FullName = $sString Then Return $oPresentation
            Case "title"
                If $oPresentation.Application.Caption = $sString Then Return $oPresentation
            Case Else
                Return SetError(2, 0, 0)
        EndSwitch
        $iCount += 1
    WEnd
EndFunc   ;==>_PPT_PresentationAttach

 

I get this 

Share this post


Link to post
Share on other sites
water

Use

MsgBox(0, "Presentation Name", $oPresentation.Name)
MsgBox(0, "Presentation FullName", $oPresentation.FullName)
MsgBox(0, "Presentation Caption", $oPresentation.Application.Caption)

to make sure you use the correct values for _PPT_PresentationAttach.
The line you marked is called when none of the presentations fits the query string.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
rg20

use your PPT script and try the below script code

but before you run it, just open PowerPoint, you should get a new presentation named "Presentation 1 - Microsoft Powerpoint" but don't save it to a directory

you can even substitue the full presentation name.

 

Once it's saved, it will then recognize the file.

 

#include "Powerpoint.au3"
#include "Visio.au3"
#include <misc.au3>
#include <File.au3>
#include <Debug.au3>

$oPPT =_PPT_Open()
$Presentations = _PPT_PresentationList($oPPT)
_ArrayDisplay($Presentations, "Sorted tree")
$oPresentation = _PPT_PresentationAttach("Presentation","title", True)

If @error Then
    MsgBox($MB_SYSTEMMODAL, "PowerPoint UDF: _PPT_PresentationAttach Example", "'" & $oPresentation & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    _PPT_Close($oPPT)
    Exit
EndIf

adding your messages into the PPT includes shows

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "\\abbvienet.com\data\R&D\R478\Excel Clinical Schedule Scripts\ppttest.au3"    
"\\abbvienet.com\data\R&D\R478\Excel Clinical Schedule Scripts\Powerpoint.au3" (144) : ==> Variable must be of type "Object".:
ConsoleWrite("Presentation Name" & $oPresentation.Name & @CRLF)
ConsoleWrite("Presentation Name" & $oPresentation^ ERROR
>Exit code: 1    Time: 0.6098

 

Edited by rg20

Share this post


Link to post
Share on other sites
water

My test crashes when i try to attach to an unsaved presentation.
As soon as I save the presentation the script works without Problem.
Seems you can't connect to a presentation that hasn't been saved yet. This is true for Office 2010. My System will be upgraded today to Office 2016.

Will check if it works for Office 2016 and Word.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

I tested with Excel and the result is the same: You can't connect to an unsaved workbook.

I think the workaround is to create the new presentation by using _PPT_PresentationNew.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
rg20
On 6/20/2017 at 1:58 AM, water said:

I tested with Excel and the result is the same: You can't connect to an unsaved workbook.

I think the workaround is to create the new presentation by using _PPT_PresentationNew.

I wish I had that option, I might have to do a keystroke temporary save, then update save and delete the temp

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • antonioj84
      By antonioj84
      Hi all to the forum guru and expert I am trying to  automate this. in the registry  I have the network profile name network 2 and network   I want to  change their  CATEGORY  to Private .  Can someone lead me in the right direction.
      Private is 1 and Public is 0
      #RequireAdmin Global $sHKLMRoot = @OSArch = "x64" ? "HKLM64" : "HKLM" RegWrite($sHKLMRoot &"\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\NewNetworks" ,'/v NetworkList /t REG_MULTI_SZ /d 00000000 /f') see  attached picture below
      Much appreaciate
       

    • PhoenixPRO
      By PhoenixPRO
      When I try to automate this install program I can not get any of the buttons to click with the "ControlClick" function or any mouse movement to move the mouse to the and click it.  My OS is Windows 10 64Bit.  I have tried both 32bit and 64bit installs of Autoit V3 to no avail.
      I could not even get the run command to start the program until I used the variation of the command below in the script.
      With the script below the install program starts but will not click the "Next" button no matter what I do.
      Any help will be greatly appreciated.
      Thanks in advance.
       
      #include <MsgBoxConstants.au3>
      Opt("MouseCoordMode", 0) ;1=absolute, 0=relative to active window, 2=client
      Local $Success
      Run(@ComSpec & " /c " & 'C:\PhoenixPro_Install\RDXUtil\RDX_Tools_setup.exe', "C:\PhoenixPro_Install\RDXUtil", @SW_HIDE )

      WinWait("RDX Tools 1.62 - InstallShield Wizard", "Welcome to the InstallShield Wizard for RDX Tools 1.62")
      WinActivate("RDX Tools 1.62 - InstallShield Wizard", "Welcome to the InstallShield Wizard for RDX Tools 1.62")
      ControlClick ("RDX Tools 1.62 - InstallShield Wizard", "Welcome to the InstallShield Wizard for RDX Tools 1.62", 1639, "left", 1) ;Next Button
    • TheWizEd
      By TheWizEd
      How do I work with 2D arrays.  I've tried this but get errors.
      Local $aTest[4][4] = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]
      ;$aTest[0][] = [10,11,12]  ; Error at []
      Local $sTest = ""
      For $i = 0 To UBound($aTest)-1
        Local $aExtract = _ArrayExtract($aTest,$i,$i)
        $sTest = $sTest & MyTest($aExtract)
      Next
      Func MyTest($aTemp)
        _ArrayDisplay($aTemp)
        ; Error at    v $aTemp
        Return String($aTemp[0]) & " - " & String($aTemp[1]) & " - " & String($aTemp[2]) & @CRLF
      EndFunc
       
       
    • AndyK70
      By AndyK70
      I'm trying to fill a ListView with all normal viewable windows to act with them.
      First I tried with WinList:
      Local $aWinList = WinList("[REGEXPTITLE:(?i)(.+)]") Local $aTmp, $iID ;~ _ArrayDisplay($aWinList) For $i = $aWinList[0][0] To 1 Step -1 ; going backwards not disturbing the index while cycling through and deleting some If StringStripWS( $aWinList[$i][0], 3) == "" Or _ Not BitAND(WinGetState($aWinList[$i][1]), $WIN_STATE_VISIBLE) Or _ BitAND(WinGetState($aWinList[$i][1]), $WIN_STATE_MINIMIZED ) Then _ArrayDelete($aWinList, $i) Else ; Window has a Title and is "visible" $aTmp = WinGetPos($aWinList[$i][1]) If $aTmp[0] < -1000 Or $aTmp[1] < -1000 Then ; Window is minimized or tray icon _ArrayDelete($aWinList, $i) EndIf EndIf Next $aWinList[0][0] = UBound($aWinList)-1 ; getting actual # of windows ; Each row is now [ID]=> [Title], [hWnd] But it keeps getting Windows which are definitely not there at least not visible:

      Those windows "Rechner", "Einstellungen", "Netflix", "Microsoft Store", ... are not there!?! 
      It should list only the first three windows, which are real.
      I even tried it with _WinAPI_ UDF:
      $hWnd = _WinAPI_GetForegroundWindow() ; Add items _GUICtrlListView_BeginUpdate($idListview) If $hWnd <> 0 Then $iI = 0 Do If _WinAPI_IsWindow($hWnd) And _WinAPI_IsWindowVisible Then _GUICtrlListView_AddItem($idListview, WinGetTitle($hWnd)) _GUICtrlListView_AddSubItem($idListview, $iI, $hWnd, 1) $iI += 1 $hWnd = _WinAPI_GetWindow($hWnd, $GW_HWNDNEXT) EndIf Until $hWnd = 0 EndIf But it is the same...
       
      How can i distinguish those invisible windows from normal ones?
      PS: I'm using Windows 10, maybe it is important to know?
    • davidacrozier
      By davidacrozier
      Hello all ~
      I am running an autoit script on Windows 10 inside VMware Workstation 12 Pro version 12.5.2.  Technically I am remoting into ESXi which has a Domain Controller (DC), WebServer, FilServer, Windows 10, etc.  Using the GUI (i.e. running explorer.exe) I am able to open several different folders successfully.  The desktop, documents, USB external all open without issue.  The network share opening gives me issues.  Whenever I attempt to open \\filserver\users\user\sharedfolder I get the documents folder instead.  I understand that the documents folder is the default for explorer.  I have also attempted to use the letter drive mapped to the network share (Z:) and receive the same result.  When I run this script on Windows 10 alone without  the VM or the ESXi I am able to open the network share without problems.  I have tried to use the net use command to designate a letter M: to the network share folder prior to running the script.  This did not work for me.  
      One additional avenue I think might work is to use the systreeview321 and _GUICtrlTreeView_FindItem to step through the tree looking for the network share.  Once found,  double click on it and see if that opens the shared network folder.  I can click inside the VM with my mouse on the network share and it opens just fine.  Not sure if running up against GUI issues, or permission issues, or what?
      Thanks in advance,
      Davida Crozier
      TestNetworkShare.au3
      This script is a subset of a much larger program, but it illustrates what I am dealing with.

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.