VBA syncing Word.OfficeUI across multiple computers

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

VBA syncing Word.OfficeUI across multiple computers

Post by New Daddy »

Below is a clode that Hans wrote, which has become my most important tool.

I've recently migrated to iMac but continue to run Windows 7 on a virtual machine. (The reason is that Word 2016 for Mac is not as customizable as Word 2013 for Windows.)

But I'm having trouble with the macro below that used to sync Word.OfficeUI across multiple Windows machines so well.

I think the reason it's not working on the virtual machine is simple -- Microsoft Office now resides on C:, while the Dropbox now resides on a different drive. (OS X has its own Dropbox, and I didn't want to create a duplicate Dropbox on the virtual machine. So I just point to the templates on the iMac's Dropbox from Word's File Locations. iMac's Dropbox is mapped as a network drive from the virtual machine's perspective.)

Is there a fix for this? In other words, is there a way to differentiate "strProfile" below between the local Word.OfficeUI and the Dropbox's Word.OfficeUI?

Code: Select all

    Sub Test()
        Dim fso As Object
        Dim strProfile As String
        Dim strPath1 As String
        Dim strPath2 As String
        Dim fil1 As Object
        Dim fil2 As Object
        Set fso = CreateObject("Scripting.FileSystemObject")
        strProfile = Environ("UserProfile")
        strPath1 = strProfile & "\DropBox\Word.officeUI"
        Set fil1 = fso.GetFile(strPath1)
        strPath2 = strProfile & "\AppData\Local\Microsoft\Office\Word.officeUI"
        Set fil2 = fso.GetFile(strPath2)
        If fil1.DateLastModified < fil2.DateLastModified Then
            fso.CopyFile strPath2, strPath1, True
        ElseIf fil1.DateLastModified > fil2.DateLastModified Then
            fso.CopyFile strPath1, strPath2, True
        End If
    End Sub

User avatar
HansV
Administrator
Posts: 78920
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VBA syncing Word.OfficeUI across multiple computers

Post by HansV »

Change the line

Code: Select all

        strPath1 = strProfile & "\DropBox\Word.officeUI"
to

Code: Select all

        strPath1 = "M:\SubFolder1\SubFolder2\DropBox\Word.officeUI"
where M:\SubFolder1\SubFolder2 is the path to the folder that contains DropBox - M is the drive letter. The names of the subfolders and also the number of subfolders in the path depends on your setup, of course.
Best wishes,
Hans

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Re: VBA syncing Word.OfficeUI across multiple computers

Post by New Daddy »

HansV wrote:Change the line

Code: Select all

        strPath1 = strProfile & "\DropBox\Word.officeUI"
to

Code: Select all

        strPath1 = "M:\SubFolder1\SubFolder2\DropBox\Word.officeUI"
where M:\SubFolder1\SubFolder2 is the path to the folder that contains DropBox - M is the drive letter. The names of the subfolders and also the number of subfolders in the path depends on your setup, of course.
Yes, that will work, but then the same macro won't work across multiple machines that have the Dropbox folder in different drives. It is important that the same macro should work across different machines, since I have it as AutoOpen.

How about if I keep the Word.officeUI in the same folder as the user template folder? Is there a VBA function that figures out the location of the user template folder? If so, the same macro will be able to parse out the Word.officeUI location no matter in which drive it is located on.

User avatar
HansV
Administrator
Posts: 78920
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: VBA syncing Word.OfficeUI across multiple computers

Post by HansV »

The user templates path is

Options.DefaultFilePath(wdUserTemplatesPath)
Best wishes,
Hans

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Re: VBA syncing Word.OfficeUI across multiple computers

Post by New Daddy »

HansV wrote:The user templates path is

Options.DefaultFilePath(wdUserTemplatesPath)
That worked! Thanks!!

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Re: VBA syncing Word.OfficeUI across multiple computers

Post by New Daddy »

HansV wrote:The user templates path is

Options.DefaultFilePath(wdUserTemplatesPath)
I'm running into two problems.

First, the line below is triggering an error on Mac.

Set fso = CreateObject("Scripting.FileSystemObject")

Is there an alternative for Mac?

[edit] I fixed the second problem below on my own.
Now I'm using a new computer on Windows 10 & Word 2016.
The same macro that used to work perfectly to sync Word.officeui is triggering an error at the line that I colored in blue below:

strProfile1 = Options.DefaultFilePath(wdUserTemplatesPath)
strProfile2 = Environ("UserProfile")
strPath1 = strProfile1 & "\Word.officeUI"
Set fil1 = fso.GetFile(strPath1)

Either Windows 10 or Word 2016 must the culprit, but I have no idea.
What's wrong?

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: VBA syncing Word.OfficeUI across multiple computers

Post by Rudi »

Do you have a reference set in the VB Editor (Tools > References) to: "Microsoft Scripting Runtime"?
In order to use the FileSystemObject, this library reference must be activated.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Re: VBA syncing Word.OfficeUI across multiple computers

Post by New Daddy »

Rudi wrote:Do you have a reference set in the VB Editor (Tools > References) to: "Microsoft Scripting Runtime"?
In order to use the FileSystemObject, this library reference must be activated.
No, I don't have that at all. Can I download it from somewhere?

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: VBA syncing Word.OfficeUI across multiple computers

Post by Rudi »

Hi,

Nothing necessary to install. The Scripting Runtime library should be available by default.

If you can open the VB editor (Alt + F11)
Then go to Tools > References in the VB Editor menu
In the dialog, scroll down looking for Microsoft Scripting Runtime
Then tick the checkbox.
Choose OK
Then try running your code again...
Image 061.jpg
Image 062.jpg
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Re: VBA syncing Word.OfficeUI across multiple computers

Post by New Daddy »

Rudi wrote:Hi,

Nothing necessary to install. The Scripting Runtime library should be available by default.

If you can open the VB editor (Alt + F11)
Then go to Tools > References in the VB Editor menu
In the dialog, scroll down looking for Microsoft Scripting Runtime
Then tick the checkbox.
Choose OK
Then try running your code again...
Maybe it's because I'm using Mac, but that library isn't in the list. (The screen shot is cut off at the bottom, but still it's not there either.)
You do not have the required permissions to view the files attached to this post.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: VBA syncing Word.OfficeUI across multiple computers

Post by Rudi »

    
Apologies for leading down the wrong path! I don't think this code is compatible for MAC. You may need to consider a macro rewrite for the MAC (if possible). I know zero about this on MAC's. Sorry.

A comment I found in a support forum suggests:
"Mac doesn't support ActiveX (it's a Windows technology), so you can't create the Scripting.FileSystemObject; it doesn't exist. (Even if it did, it's based on FAT32 or NTFS file systems, so it wouldn't work on OS X anyway."
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

New Daddy
4StarLounger
Posts: 437
Joined: 05 Nov 2012, 20:02

Re: VBA syncing Word.OfficeUI across multiple computers

Post by New Daddy »

Rudi wrote:    
Apologies for leading down the wrong path! I don't think this code is compatible for MAC. You may need to consider a macro rewrite for the MAC (if possible). I know zero about this on MAC's. Sorry.

A comment I found in a support forum suggests:
"Mac doesn't support ActiveX (it's a Windows technology), so you can't create the Scripting.FileSystemObject; it doesn't exist. (Even if it did, it's based on FAT32 or NTFS file systems, so it wouldn't work on OS X anyway."
No prob.

Do you know where I can seek help for writing macro for Mac? People here seem to be more Windows-oriented.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: VBA syncing Word.OfficeUI across multiple computers

Post by Rudi »

Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
Charles Kenyon
5StarLounger
Posts: 641
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: VBA syncing Word.OfficeUI across multiple computers

Post by Charles Kenyon »

The OfficeUI file is a very crude tool for sharing customizations. Think wood axe vs. scalpel.

For the type of sharing you are talking about, much, much, simpler, IMO, is saving the customizations in a global template using XML. In my experience, this will translate across versions within Windows and may also work on the Mac (depending on vba coding issues).

http://www.addbalance.com/usersguide/te ... htm#Global
http://gregmaxey.com/word_tip_pages/cus ... _main.html
http://addbalance.com/word/QATmodification.htm