Results 1 to 4 of 4

Thread: Portable VBA?

  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    146
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Portable VBA?

    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

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Portable VBA?

    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

  3. #3
    2 Star Lounger
    Join Date
    Jun 2001
    Posts
    146
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Portable VBA?

    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

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Portable VBA?

    <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15>

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •