• Portable VBA?

    Author
    Topic
    #356694

    I created AutoOpen and AutoClose macros for a file, which worked perfectly on my PC. When the file is opened on other PCs, an error message comes up about not being able to access an object library. Is there a local setting in my Word 2000 VBA that could be messing things up?

    Thanks,
    Bob

    Viewing 1 reply thread
    Author
    Replies
    • #528368

      Bob,

      Maybe there is something specifically in your AutoOpen or AutoClose code that is using a reference that’s set on your machine but perhaps not on others? – can you post the relevant code?

      Gary

      • #528458

        Gary,

        Here’s the AutoOpen code, with company-specific info x’d out:

        *****************

        Sub AutoOpen()

        Dim UserMessage As String
        Dim Release As String
        Dim UsrNme As String
        Dim Solution As String
        Dim Change As String
        Dim DocCheck As Boolean

        OriginalUserName = Application.UserName
        UsrNme = OriginalUserName

        Do Until Release = “xxx” Or Release = “xxx” Or Release = “x” Or Release = “xxx”

        UserMessage = “What xxxx or xxx are you working on? You must enter xxxx, xxxx(for xxxx), xxxx (for xxxx), or R (read-only).”
        Release = InputBox(UserMessage, “xxxx”, “”)

        If Release = “xxxx” Or Release = “xxxx” Or Release = “r” Then

        Release = UCase(Release)

        End If

        If Release “xxxx” And Release “xxxx” And Release “R” And Release “xxxx” Then

        MsgBox “You must enter xxxx, xxxx, xxxx, or R (read-only).”

        End If

        Loop

        If ActiveDocument.ProtectionType = wdAllowOnlyRevisions Or ActiveDocument.ProtectionType = wdAllowOnlyComments Then

        ActiveDocument.Unprotect Password:=”xxxx”

        End If

        DocCheck = False

        If Release = “xxxx” Then

        Do Until DocCheck = True

        UserMessage = “xxxx”
        Release = InputBox(UserMessage, “xxxx”, “”)
        Release = UCase(Release)
        DocCheck = InStr(Release, “xxxx”) Or InStr(Release, “xxxx”)

        Loop

        End If

        If Release = “R” Then

        ActiveDocument.TrackRevisions = False

        ActiveDocument.Protect Password:=”xxxx”, NoReset:=False, Type:= _
        wdAllowOnlyComments

        MsgBox “You have accessed this document for read-only purposes. You cannot make any changes to the document.”

        Else

        ActiveDocument.Protect Password:=”xxxx”, NoReset:=False, Type:= _
        wdAllowOnlyRevisions
        Application.UserName = UsrNme + “” + Release
        Application.UserAddress = “”
        ActiveDocument.TrackRevisions = True
        MsgBox “Change-tracking has been turned on in this document. While you are working in this document, your Word user name will be ” + Application.UserName + “. It will be automatically changed back to ” + UsrNme + ” when you close this document.”

        End If

        End Sub

        ************

        Also, I checked the object references on both my machine and the user’s machine, and they were the same.

        Thanks,
        Bob

    • #528469

      hmmn

      Is this Word 2000? The user may need to change his/her macro security from High to Medium. High ignores all macros unless they are digitally signed. Medium prompts with the enable/disable macros dialog. Low is for insane people as it will run any macro.

    Viewing 1 reply thread
    Reply To: Portable VBA?

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: