![]() |
#1
|
|||
|
|||
![]()
I'm sharing a lot of my code with coworkers and would like to be able to write in an option to update the code automatically as I release more.
I'm thinking that by using Auto_Open the code will read down a specific file path, and if "newcode.dotm" exists, it will bring up a userform that gives the user the option to copy that code to the startup folder. Is this option available via wordvba? I know it's someone hard to access the startup folder while word is being used, so is it possible to have code close word, replace "oldcode.dotm" with "newcode.dotm" in the startup folder, then have it reboot word? I know this might be a bit of a stretch (I could always have people manually update it), but they're not very tech savvy and this option would make things very easy for everyone. Thanks for any input/ideas as to how I could make this work. This is how I'm thinking of starting it Code:
Function FileThere2(FileName As String) As Boolean FileThere = (Dir(FileName) > "") End Function Sub UpdateCode() If FileThere("G:\SalesOffice\Public\user1\newcode.dotm") Then 'FileThere is a private function that searches for the newer version in the G Drive MsgBox Prompt:="oldcode has detected that there is a better version. Oldcode will now prompt you to download newcode", _ Buttons:=vbExclamation, _ Title:="Outdated" frmDownloadNewCodeShow 'This prompts the user to download new code. Else 'Do Nothing End If End Sub |
#2
|
||||
|
||||
![]()
Unless your colleagues configure their Word installations to allow trusted access to the VBA project model - something that is dangerous to have as a default state - your scheme won't work.
Instead, if your updating code that belongs in a template they're to use, simply roll out the new template, preferably by having the users concerned joined to a group whose group templates folder is one you can update. That way, they don't have to do anything.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
Hi Paul,
So about half of my code is held in a group folder that I can update there, so that's good... Unfortunately, the other half is held within userforms that really needs to be updated within their STARTUP folders. I figured that by using a prompt in a userform that they initiate themselves (by actually going to macros -> view -> run, not using Auto_Open) I'd be able to give whatever privileges are needed to make the update - Is this not possible? Worst come to worst, I'd figure I can at least have the code close out of Microsoft Word and open the folder containing the "newcode.dotm", so all they'd have to do is copy it and drag it to their STARTUP folder again. Do you think this is the best, tangible solution? Perhaps the code can open 2 folders side by side, one containing the new code, the other containing the STARTUP folder, so all they have to do is drag and drop? |
#4
|
||||
|
||||
![]()
You cannot grant such access programmatically - virus writers would have a field day if you could!
If your users really, really, really need to have the templates with the userforms in their startup folders, either you'll have to send them the new files, with instructions on how to replace the files - perhaps even a macro to do the file copying - (forget module updating), or have a System Administrator (or someone else with suitable privileges and know-how) do the file replacement.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Great point. I will talk to my system administrator here about that solution. Thanks!
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
rdross51 | Word VBA | 2 | 06-01-2016 07:05 PM |
![]() |
laurieli | Office | 7 | 01-17-2016 08:56 AM |
How to constantly and automatically copy the contacts from a shared folder to my private folder? | Paulo | Outlook | 0 | 08-16-2015 12:06 PM |
![]() |
cc.caroline15 | Excel Programming | 6 | 01-12-2015 10:04 PM |
Office Startup folder not default trusted location - shortcut | Charles Kenyon | Word VBA | 0 | 08-27-2012 09:36 AM |