Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have built an application that will be used by many people. What I would like to achieve is to have a different bookmark selected at sheet selected for each user (by user I mean Active Directory user). I know this could be achieved by Macro, but could s.o. help me with the code pls.
Best,
Maya
Depends a bit, which fields to be selected, if it is just the user and you have also the user as field in your application then the easiest might be
SUB SelectUser
LET sUser = ActiveDocument.GetApplication.GetProperties.UserName
ActiveDocument.Fields("User").Select sUser
END SUB
The UserName reverts with the domain, which you probably may have to filterout. You may link this macro with the On Activate Sheet-even or the like
HTH
Peter
Depends a bit, which fields to be selected, if it is just the user and you have also the user as field in your application then the easiest might be
SUB SelectUser
LET sUser = ActiveDocument.GetApplication.GetProperties.UserName
ActiveDocument.Fields("User").Select sUser
END SUB
The UserName reverts with the domain, which you probably may have to filterout. You may link this macro with the On Activate Sheet-even or the like
HTH
Peter
Thank you very much Peter, this was really helpful and was exactly what I needed.
That's the actual code that I used in my application:
SUB ApplyInitialBookmark
ActiveDocument.Fields("User").Select ActiveDocument.GetApplication.GetProperties.UserName
ActiveDocument.Fields("Object").Select REPLACE(ActiveDocument.GetLayout.ActiveSheetId,"Document\","")
SET bookmarkNames = ActiveDocument.Fields("Bookmark").GetPossibleValues
IF bookmarkNames.Count>0 THEN
bookmarkName=bookmarkNames.Item(i).Text
ActiveDocument.RecallDocBookmark bookmarkName
END IF
ActiveDocument.Fields("User").Clear
ActiveDocument.Fields("Object").Clear
END SUB