Jump to content

File locations in office


Recommended Posts

I'm looking around for a script that has a gui that would allow for a user to easily set their default file location in Office 2003. Word, Excel, Powerpoint, Access, Outlook. To be more precise, In word, the default location is "My Documents" I want to make it so the default would be H:\. I know I could do a script that would do the mouseclicks, but I have to do word, excel, powerpoint, access, and outlook. It would seem to me that is somewhat clumsy. I found a VB script that talks about it, but I found that too confusing, and the learning curve is something I do not have time to for. I also found a reference for fixing the issue in the registry, but that only talks about outlook, not the other parts. Has anyone got any info so I solve this, or even better, a script that does this?

Link to comment
Share on other sites

$savepath = "H:\"
RegWrite("HKCU\Software\Microsoft\Office\11.0\Outlook\Options","DefaultPath","REG_SZ",$savepath)
RegWrite("HKCU\Software\Microsoft\Office\11.0\Excel\Options","DefaultPath","REG_SZ",$savepath)
RegWrite("HKCU\Software\Microsoft\Office\11.0\Word\Options","DOC-PATH","REG_SZ",$savepath)
RegWrite("HKCU\Software\Microsoft\Office\11.0\PowerPoint\RecentFolderList","DEFAULT","REG_EXPAND_SZ",$savepath)

Works!

Edit: now with powerpoint. BTW, I did not figure this out using the the WebterNet, or from searching goople or whatever it's called. I created a folder called C:\alskejroaierjlae, and started up RegMon from SysInternals, and had it filter by "alskejroaierjlae". Then, one by one, I set the save path in each program to that folder. Then I went back to RegMon to see who wrote what where. Easy peasy.

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

Ok, I made a script to make it simple for users to select their network folder. I ran into a problem that I can't figure out. -

If the user selects a drive path that I do not wish for them to use, they get a errro message. If they then select a drive that is allowed, then click on continue, the message box shows up again. Depending on how many times the wrong drive is selected is how many times the msgbox will come back when clicking on continue. Not sure on how to solve it. Here is my code:

#include <GuiConstants.au3>
dim $savepath, $msg, $chk
GuiCreate("", 392, 138,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Pick your network user folder", 20, 20, 360, 30)
$Button_2 = GuiCtrlCreateButton("Ok and exit", 150, 90, 100, 30)
GUICtrlSetState($Button_2, $GUI_DISABLE)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        _select()
        if $msg = 10 then 
            do
                _select()               
            until $msg = 11 or $msg = 2
        endif               
    Case $msg = $Button_2
        _paths()    
        exit
    Case Else
        ;;;
    EndSelect
WEnd
Exit

func _select()
    $savepath = FileSelectFolder("Select your network folder you keep your files.", "")
    _path1()
EndFunc

func _path1()   
    if $savepath = "" then 
        sleep(1)
    else    
        _path2()
    endif   
EndFunc

Func _path2()
    $chk = StringLeft($savepath, 12)
    $chk2 = stringinstr($savepath, "A:\")
    $chk3 = stringinstr($savepath, "C:\")
    $chk4 = stringinstr($savepath, "D:\")
    $chk5 = stringinstr($savepath, "E:\")
    $chk6 = stringinstr($savepath, "F:\")   
        if $chk2 > 0 then
            MsgBox(0, "Error", "You can not select a path on the ""A"" drive. Please select again")
            _select()
        endif       
        if $chk3 > 0 then
            MsgBox(0, "Error", "You can not select a path on the ""C"" drive. Please select again")
            _select()
        endif   
        if $chk4 > 0 then
            MsgBox(0, "Error", "You can not select a path on the ""D"" drive. Please select again")
            _select()
        endif
        if $chk5 > 0 then
            MsgBox(0, "Error", "You can not select a path on the ""E"" drive. Please select again")
            _select()
        endif   
        if $chk6 > 0 then
            MsgBox(0, "Error", "You can not select a path on the ""F"" drive. Please select again")
            _select()
        endif       
        if $chk = "my computer" then
            MsgBox(0, "Error", "You can not select ""My Computer"". Please select again")
            _select()
        endif
        _fold() 
        GUICtrlSetData($Button_1, $savepath)
EndFunc 
func _fold()
        $msg = MsgBox(38, "Question", "Is the path: "&@CRLF _
        &""&@CRLF _
        &$savepath& @CRLF _
        &""&@CRLF _
        &" correct?")
        if $msg = 11 then GUICtrlSetState($Button_2, $GUI_ENABLE)
        if $msg = 2 then exit
EndFunc
func _paths()
RegWrite("HKCU\Software\Microsoft\Office\11.0\Outlook\Options","DefaultPath","REG_SZ",$savepath)
RegWrite("HKCU\Software\Microsoft\Office\11.0\Excel\Options","DefaultPath","REG_SZ",$savepath)
RegWrite("HKCU\Software\Microsoft\Office\11.0\Word\Options","DOC-PATH","REG_SZ",$savepath)
RegWrite("HKCU\Software\Microsoft\Office\11.0\PowerPoint\RecentFolderList","DEFAULT","REG_EXPAND_SZ",$savepath)
EndFunc
Link to comment
Share on other sites

  • Moderators

Why even have functions, you aren't returning anything, and you don't pass any parameters?

To answer your question, You are Using 6 different If statements, that all call select again... It goes through every one of those 6... Structure is what you are missing. You don't need more than 1 StringInStr.

All in all, it's a complete mess... I fixed it a tad:

#include <GuiConstants.au3>
dim $savepath, $msg, $chk
GuiCreate("", 392, 138,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Button_1 = GuiCtrlCreateButton("Pick your network user folder", 20, 20, 360, 30)
$Button_2 = GuiCtrlCreateButton("Ok and exit", 150, 90, 100, 30)
GUICtrlSetState($Button_2, $GUI_DISABLE)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_1
        _select();You never get GUIGetMsg again.
        If @error Then
            Do
                _select()            
            Until Not @error
        endif            
    Case $msg = $Button_2
        _paths()   
        exit
    Case Else
        ;;;
    EndSelect
WEnd
Exit

func _select()
    $savepath = FileSelectFolder("Select your network folder you keep your files.", "")
    _path1()
EndFunc

func _path1()   
    if $savepath = "" then
        sleep(1)
    else    
        _path2()
    endif   
EndFunc

Func _path2()
    If StringLeft($savepath, 12) = 'my computer' Then
        MsgBox(16, 'Error', "You can not select ""My Computer"". Please select again")
        Return SetError(1, 0, 0)
    ElseIf StringInStr('a:\c:\d:\e:\f:\', StringLeft($savepath, 3)) Then
        MsgBox(16, 'Error', 'You can not select a path on the "' & StringLeft($savepath, 3) & '" drive.  Please select again')
        Return SetError(1, 0, 0)
    EndIf
        _fold() 
        GUICtrlSetData($Button_1, $savepath)
EndFunc 
func _fold()
        $msg = MsgBox(38, "Question", "Is the path: "&@CRLF _
        &""&@CRLF _
        &$savepath& @CRLF _
        &""&@CRLF _
        &" correct?")
        if $msg = 11 then GUICtrlSetState($Button_2, $GUI_ENABLE)
        if $msg = 2 then exit
EndFunc
func _paths()
;RegWrite("HKCU\Software\Microsoft\Office\11.0\Outlook\Options","DefaultPath","REG_SZ",$savepath)
;RegWrite("HKCU\Software\Microsoft\Office\11.0\Excel\Options","DefaultPath","REG_SZ",$savepath)
;RegWrite("HKCU\Software\Microsoft\Office\11.0\Word\Options","DOC-PATH","REG_SZ",$savepath)
;RegWrite("HKCU\Software\Microsoft\Office\11.0\PowerPoint\RecentFolderList","DEFAULT","REG_EXPAND_SZ",$savepath)
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...