Page 1
MicrosoftOfficeObjectModelAnswerWizard AnswerWizardFiles
AssistantBalloon
BalloonCheckboxesBalloonCheckbox
BalloonLabelsBalloonLabel
COMAddInsCOMAddIn
CommandBarButtonCommandBarCommandBarControlsCommandBarControl
CommandBarComboBoxCommandBarCommandBarControlsCommandBarControl
CommandBarPopupCommandBarCommandBarControlsCommandBarControl
CommandBars
Page 2
CommandBarCommandBarControlsCommandBarControl
DocumentLibraryVersionsDocumentLibraryVersion
DocumentPropertiesDocumentProperty
FileDialogFileDialogFiltersFileDialogFilter
FileDialogSelectedItems
FileSearchFileTypesFoundFilesPropertyTestsPropertyTest
SearchFoldersScopeFolderScopeFolders
SearchScopesSearchScopeScopeFolderScopeFolders
HTMLProjectHTMLProjectItemsHTMLProjectItem
Page 3
LanguageSettings
MsoEnvelope
NewFile
ODSOColumnsODSOColumn
ODSOFiltersODSOFilter
OfficeDataSourceObject
PermissionUserPermission
ScriptsScript
SharedWorkspaceSharedWorkspaceFilesSharedWorkspaceFile
SharedWorkspaceFoldersSharedWorkspaceFolder
SharedWorkspaceLinksSharedWorkspaceLink
SharedWorkspaceMembersSharedWorkspaceMember
SharedWorkspaceTasksSharedWorkspaceTask
SignatureSetSignature
Page 4
SmartDocument
Sync
WebPageFontsWebPageFont
Page 5
NewObjectsVisittheOfficeDeveloperCenterontheMicrosoftDeveloperNetworkWebsiteforthelatestinformationaboutprogrammingwithOffice2003,includingproductnews,technicalarticles,downloads,andsamples.
ThefollowingtablelistsobjectsaddedtotheMicrosoftOffice2003objectmodel.
Object Description
DocumentLibraryVersion Asinglesavedbackupcopyorversionofashareddocument.
DocumentLibraryVersions AcollectionofDocumentLibraryVersionobjects.
Permission Managesdocumentpermissions;also,acollectionofUserPermissionobjects.
SharedWorkspace Managesadocumentsavedinasharedworkspace.
SharedWorkspaceFile Afilesavedinasharedworkspace.SharedWorkspaceFiles AcollectionofSharedWorkspaceFileobjects.SharedWorkspaceFolder Asubfolderinasharedworkspace.
SharedWorkspaceFolders AcollectionofSharedWorkspaceFolderobjects.
SharedWorkspaceLink Alinksavedinasharedworkspace.SharedWorkspaceLinks AcollectionofSharedWorkspaceLinkobjects.SharedWorkspaceMember Auserofasharedworkspace.
SharedWorkspaceMembers AcollectionofSharedWorkspaceMemberobjects.
SharedWorkspaceTask Atasksavedinasharedworkspace.SharedWorkspaceTasks AcollectionofSharedWorkspaceTaskobjects.
SmartDocument ManagesanattachedXMLexpansionpackwhichtransformsadocumentintoasmartdocument.
Sync Managesthesynchronizationbetweenthelocalcopyandtheservercopyofashareddocument.
Page 6
UserPermission Asetofpermissionsonadocumentforasingleuser.
Page 7
NewProperties(AlphabeticalList)VisittheOfficeDeveloperCenterontheMicrosoftDeveloperNetworkWebsiteforthelatestinformationaboutprogrammingwithOffice2003,includingproductnews,technicalarticles,downloads,andsamples.
ThefollowingtablelistspropertiesaddedtotheMicrosoftOffice2003objectmodel(sortedalphabetically).
NewProperty Object(s)AssignedTo SharedWorkspaceTaskComments DocumentLibraryVersionConnected SharedWorkspace
CreatedBySharedWorkspaceFile,SharedWorkspaceFolder,SharedWorkspaceLink,SharedWorkspaceTask
CreatedDateSharedWorkspaceFile,SharedWorkspaceFolder,SharedWorkspaceLink,SharedWorkspaceTask
DocumentAuthor PermissionDomainName SharedWorkspaceMemberDueDate SharedWorkspaceTaskEmail SharedWorkspaceMemberEnableTrustedBrowser PermissionErrorType SyncExpirationDate UserPermissionFolderName SharedWorkspaceFolderFolders SharedWorkspaceIsVersioningEnabled DocumentLibraryVersions
ItemCountExceeded
SharedWorkspaceFiles,SharedWorkspaceFolders,SharedWorkspaceLinks,SharedWorkspaceMembers,SharedWorkspaceTasks
Page 8
LastRefreshed SharedWorkspaceLastSyncTime SyncLinks SharedWorkspaceMembers SharedWorkspaceModified DocumentLibraryVersion
ModifiedBy
SharedWorkspaceFile,SharedWorkspaceFolder,SharedWorkspaceLink,SharedWorkspaceTask,DocumentLibraryVersion
ModifiedDateSharedWorkspaceFile,SharedWorkspaceFolder,SharedWorkspaceLink,SharedWorkspaceTask
Notes SharedWorkspaceLinkPermission UserPermissionPermissionFromPolicy PermissionPolicyDescription PermissionPolicyName PermissionRequestPermissionURL PermissionSolutionID SmartDocumentSolutionURL SmartDocumentSourceURL SharedWorkspaceStatus SharedWorkspaceTask,SyncStoreLicenses PermissionTasks SharedWorkspaceUserId UserPermissionWorkspaceLastChangedBy Sync
Page 9
NewProperties(byObject)VisittheOfficeDeveloperCenterontheMicrosoftDeveloperNetworkWebsiteforthelatestinformationaboutprogrammingwithOffice2003,includingproductnews,technicalarticles,downloads,andsamples.
ThefollowingtablelistspropertiesaddedtotheMicrosoftOffice2003objectmodel(sortedbyobjectname).
Object NewPropertiesDocumentLibraryVersion Comments,Modified,ModifiedByDocumentLibraryVersions IsVersioningEnabled
Permission
DocumentAuthor,EnableTrustedBrowser,PermissionFromPolicy,RequestPermissionURL,StoreLicenses,PolicyDescription,PolicyName
SharedWorkspace Connected
SharedWorkspaceFile CreatedBy,CreatedDate,ModifiedBy,ModifiedDate
SharedWorkspaceFiles ItemCountExceeded
SharedWorkspaceFolder CreatedBy,CreatedDate,FolderName,ModifiedBy,ModifiedDate
SharedWorkspace FoldersSharedWorkspaceFolders ItemCountExceededSharedWorkspace LastRefreshed
SharedWorkspaceLink Notes,CreatedBy,CreatedDate,ModifiedBy,ModifiedDate
SharedWorkspace LinksSharedWorkspaceLinks ItemCountExceededSharedWorkspaceMember DomainName,EmailSharedWorkspace MembersSharedWorkspaceMembers ItemCountExceededSharedWorkspace SourceURL
Page 10
SharedWorkspaceTask AssignedTo,CreatedBy,CreatedDate,DueDate,ModifiedBy,ModifiedDate
SharedWorkspace TasksSharedWorkspaceTasks ItemCountExceededSharedWorkspaceTask StatusSmartDocument SolutionID,SolutionURL
Sync ErrorType,LastSyncTime,Status,WorkspaceLastChangedBy
UserPermission ExpirationDate,Permission,UserId
Page 11
NewMethods(AlphabeticalList)VisittheOfficeDeveloperCenterontheMicrosoftDeveloperNetworkWebsiteforthelatestinformationaboutprogrammingwithOffice2003,includingproductnews,technicalarticles,downloads,andsamples.
ThefollowingtablelistsmethodsaddedtotheMicrosoftOffice2003objectmodel(sortedalphabetically).
NewMethod ObjectApplyPolicy PermissionCreateNew SharedWorkspaceDisconnect SharedWorkspaceGetUpdate SyncOpenVersion SyncPickSolution SmartDocumentPutUpdate SyncRefresh SharedWorkspaceRefreshPane SmartDocumentRemoveAll PermissionRemoveDocument SharedWorkspaceResolveConflict SyncRestore DocumentLibraryVersionUnsuspend Sync
Page 12
NewMethods(byObject)VisittheOfficeDeveloperCenterontheMicrosoftDeveloperNetworkWebsiteforthelatestinformationaboutprogrammingwithOffice2003,includingproductnews,technicalarticles,downloads,andsamples.
ThefollowingtablelistsmethodsaddedtotheMicrosoftOffice2003objectmodel(sortedbyobjectname).
NewMethod ObjectDocumentLibraryVersion RestorePermission ApplyPolicy,RemoveAll
SharedWorkspace CreateNew,Disconnect,Refresh,RemoveDocument
SmartDocument PickSolution,RefreshPane
Sync GetUpdate,OpenVersion,PutUpdate,ResolveConflict,Unsuspend
Page 13
SecurityNotesforMicrosoftOfficeSolutionDevelopersAboutSettingMicrosoftOffice2003SecurityinaTestingEnvironmentMicrosoftOffice2003MacroandAdd-inSecuritySettingsMatrixAboutEnabling"Trustallinstalledadd-insandtemplates"AboutModifyingtheMicrosoftWindowsRegistryAboutMakingMicrosoftWindowsApplicationProgrammingInterface(API)FunctionCallsAboutDigitalCodeSigningAboutSecureDeploymentofManagedCOMAdd-insinMicrosoftOffice2003AboutAutomatingtheVisualBasicEditorAboutPasswordsAboutMicrosoftOfficeOutlook2003SecuritySettings
Page 14
AboutSettingMicrosoftOffice2003SecurityinaTestingEnvironment
ToinstallandrunanunsignedCOMadd-inorMicrosoftVisualBasicforApplications(VBA)macro,thesecuritysettingsintheSecuritydialogbox(Toolsmenu,Macrosubmenu,Securitycommand)mustbesettoMedium,withtheTrustallinstalledadd-insandtemplatescheckboxcleared.Itisstronglyrecommendedthatyoudothisonlyinatestingenvironment.Afteryouhavecompletedyourtesting,setthesecuritylevelbacktoVeryHighorHigh.
CautionBysettingthesecurityleveltoMedium,withtheTrustallinstalledadd-insandtemplatescheckboxcleared,userswillhavethechoicetoeitherenableordisableunsignedCOMadd-insandVBAmacroswhentheyareprompted.IfyoursecuritylevelissettoVeryHighorHigh,withtheTrustallinstalledadd-insandtemplatescheckboxcleared,allunsignedCOMadd-insandVBAmacroswillbedisabledautomatically.Therefore,itisstronglyrecommendedthatalluserskeeptheirsecuritylevelssettoVeryHighorHighwiththeTrustallinstalledadd-insandtemplatescheckboxcleared.
Page 15
MicrosoftOffice2003MacroandAdd-inSecuritySettingsMatrix
ThefollowingtableliststheavailableMicrosoftOffice2003securitysettings,alongwiththeircorrespondingbehaviors,intheSecuritydialogbox(Macrossubmenu,Toolsmenu).
Office2003macroandadd-insecuritysettingoptions
Securitylevel
Digitallysigned?
Fromtrustedsources? Office2003will
VeryHigh Yes Yes Loadtheadd-inormacrosilently
Yes No Notloadtheadd-inormacro No N/A Notloadtheadd-inormacroHigh Yes Yes Loadtheadd-inormacrosilently
Yes No Prompttotrustthesourceandenabletheadd-inormacrotorun
No N/A Notloadtheadd-inormacroMedium Yes Yes Loadtheadd-inormacrosilently
Yes No Prompttotrustthesourceandenabletheadd-inormacrotorun
No N/A Prompttoenableordisabletheadd-inormacro
Low YesorNo YesorNo Loadtheadd-inormacrosilently
NoteTheavailabilityof,andoptionswithin,theSecuritydialogboxvarydependingonthespecificOfficeapplication.Additionally,specificOfficeapplicationssilentlyloadsignedadd-insandmacrosonlyfromspecificdirectories,alongwithregisteredCOMadd-insandsmarttagsrecognizers.
Formoreinformationonthesesettingsandontheotherissuesdiscussedinthistopic,searchfor"Officemacrosecurity"intheMicrosoftDeveloperNetwork(MSDN)Library.
Page 16
AboutEnabling"Trustallinstalledadd-insandtemplates"
TheTrustallinstalledadd-insandtemplatescheckboxiscommonlymisunderstood.Bydefaultitisenabled,butMicrosoftrecommendsthatcustomerswithhighsecurityrequirementsdisableit,andthisisagood"defenseindepth"approach.
IfyouhavenoneedtorununsignedpersonalmacrosorunsignedCOMadd-ins,youshoulddisablethisoption.WhenOfficeapplicationsecuritylevelissettoVeryHighorHigh,withtheTrustallinstalledadd-insandtemplatesoptiondisabled,alladd-insandtemplatesthatarenotsignedwillautomaticallybedisabled.Iftheadd-insandtemplatesaresignedusingacertificatenotlistedintheTrustedSourceslist,auserwillbepromptedtotrustthesourceinordertoallowtheadd-inortemplatetorun.
EnablingtheTrustallinstalledadd-insandtemplatescheckboxwillallowallCOMadd-insthathavebeeninstalledintheregistry(whichrequiresadministrativeprivileges)orVBAmacrosthatarestoredinyourpersonalorworkgrouplocationstorun,regardlessofwhethertheyaresignedornot.Itshouldalsobenotedthatend-usersdonotneedadministrativeprivilegestoinstallVBAmacrostocertaintemplateandstartupfolders.ExamplesoftheselocationsinOfficeWord2003are:
\DocumentsandSettings\<username>\ApplicationData\Microsoft\Word\STARTUP\DocumentsandSettings\<username>\ApplicationData\Microsoft\Templates
WiththeTrustallinstalledadd-insandtemplatesoptionenabled,youcanbeattackedifyoudownload,register,andrunamaliciousCOMadd-inorifyourunamalicioustemplatefromsomeoneelse.
IfyoudecidetorunpersonalVBAmacrosortorunlocallyinstalledCOMadd-ins,andyoudon'twanttopurchaseadigitalcertificate,butyouwanttodisabletheTrustallinstalledadd-insandtemplatesoption,herearetheavailablealternatives:
Page 17
SignyourpersonalVBAmacrosorlocallyinstalledCOMadd-insusingatestcertificatecreatedusingeitherselfcert.exeorAuthenticodetools,dependingonwhetherit'samacrooradd-in.Thisway,youcankeepyoursecuritysettingssettoVeryHighorHigh,withtheTrustallinstalledadd-insandtemplatesoptiondisabled.Formoreinformationonhowtogenerateatestcertificate,refertotheAboutDigitalCodeSigningsectionbelow.SetyourOfficeapplicationsecurityleveltoMediumwithTrustallinstalledadd-insandtemplatesdisabled.Withthesesecuritysettings,youwillbepromptedtoenableordisableaCOMadd-inorVBAmacrowhentheapplicationislaunched.It'sstronglyrecommendedthatyouusethesesettingsonlyinatestingenvironment.
Page 18
AboutModifyingtheMicrosoftWindowsRegistry
ModifyingtheMicrosoftWindowsregistryinanymanner,whetherthroughtheRegistryEditororprogrammatically,alwayscarriessomedegreeofrisk.Incorrectmodificationcancauseseriousproblemsthatmayrequireyoutoreinstallyouroperatingsystem.Itisalwaysagoodpracticetobackupacomputer'sregistryfirstbeforemodifyingit.IfyouarerunningMicrosoftWindowsNT,MicrosoftWindows2000,MicrosoftWindowsXP,orMicrosoftWindowsServer2003,youshouldalsoupdateyourEmergencyRepairDisk(ERD).
Forinformationabouthowtoedittheregistry,viewthe"ChangingKeysandValues"HelptopicintheRegistryEditor(Regedit.exe)orthe"AddandDeleteInformationintheRegistry"and"EditRegistryInformation"topicsintheRegistryEditor(Regedt32.exe).
Page 19
AboutMakingMicrosoftWindowsApplicationProgrammingInterface(API)FunctionCalls
BeforecallingMicrosoftWindowsAPIfunctions,youshouldunderstandhowargumentsanddatatypesarehandledbytheWindowsAPIDLLs.IncorrectlycallingWindowsAPIfunctionsmayresultininvalidpagefaultsorotherunexpectedbehaviors.FormoreinformationoncallingWindowsAPIfunctions,seethetopic"TheWindowsAPIandOtherDynamic-LinkLibraries"intheMicrosoftOffice2003DeveloperOnlineDocumentationortheMicrosoftDeveloperNetwork(MSDN)Library.
Page 20
AboutDigitalCodeSigning
Manysecurity-conscioususersandadministratorssettheirMicrosoftOffice2003securitylevelstoVeryHighorHighwiththeTrustallinstalledadd-insandtemplatescheckboxcleared(locatedintheSecuritydialogbox,Macrosubmenu,Toolsmenu),whichishighlyrecommended.Withthesesettings,asignedandtrustedCOMadd-inorVBAmacrowillbeloaded,andanon-signedCOMadd-inorVBAmacrowillbedisabledautomatically.TheonlytimeauserwillbepromptedtoeitherenableordisableaCOMadd-inorVBAmacroiswhenaCOMadd-inorVBAmacroissignedbutthesoftwarepublisherisnotincludedintheTrustedSourceslist.
MicrosoftAuthenticodetechnologyallowssoftwarepublisherstodigitallysignexecutable(EXE)files,ActiveXcontrol(OCX)files,cabinet(CAB)files,anddynamic-linklibrary(DLL)files.Forastep-by-stepguideonhowtodigitallysignaCOMadd-inusingMicrosoftAuthenticodetechnology,searchfor"digitalcodesigning"intheMSDNLibrary.
Page 21
AboutSecureDeploymentofManagedCOMAdd-insinMicrosoftOffice2003
TocomplywithOffice2003security,managedCOMadd-ins(COMadd-instargetingthecommonlanguageruntime)mustbedigitallysigned,andusers'securitysettingsshouldbesettotheirhighestlevels.Additionally,youwillneedtoincorporateintoyourmanagedCOMadd-inprojectasmallunmanagedproxycalledashiminordertoavoidunexpectedsecuritywarnings.Fordetails,searchfor"deploymentmanagedadd-ins"intheMSDNLibrary.
Page 22
AboutAutomatingtheVisualBasicEditor
InOffice2003,whencallingthefeaturesoftheMicrosoftVisualBasicforApplicationsExtensibilityobjectmodel,youmayreceiveanerrormessagethatprogrammaticaccesstotheVisualBasicprojectisnottrusted.Topreventthismessagefromappearing,pointtoMacroontheToolsmenu,andthenclickSecurity.OntheTrustedSourcestab,checktheTrustaccesstoVisualBasicProjectbox.Bycheckingthisbox,macrosinanydocumentsthatyouopencanaccessthecoreMicrosoftVisualBasicobjects,methods,andproperties,whichrepresentsapossiblesecurityhazard.ThedefaultbehaviorinOffice2003istonotallowmacrostoprogrammaticallyaccesstheVisualBasicobjectmodel.TherecommendedbehavioristochecktheTrustaccesstoVisualBasicProjectboxonlyforthedurationofamacrothataccessestheVisualBasicobjectmodel.TheTrustaccesstoVisualBasicProjectboxshouldbeuncheckedafterthemacrohasfinishedrunning.
Page 23
AboutPasswords
Avoidusinghard-codedpasswordsinyourapplications.Ifapasswordisrequiredinaprocedure,requestthepasswordfromtheuser,storeitinavariable,andthenusethevariableinyourcode.
Alwaysusestrongpasswords.Strongpasswordsshouldcontain:
Bothlowercaseanduppercasecharacters.Numbers.Symbols(suchas#,$,%,and^).Atleasteightcharacters.
Strongpasswordsshouldnotcontainpatterns,themes,orwordsfoundinadictionary.
Examplesofstrongpasswordsinclude:
$tR0n9p@$sG80dn[s$M4!
NoteYoushouldchangeyourpasswordfrequently;forexample,everyonetothreemonths.
Page 24
AboutMicrosoftOfficeOutlook2003SecuritySettings
COMAdd-insUsingDefaultSecurity
InMicrosoftOfficeOutlook2003,allCOMadd-insthatrunonacomputerwhichisnotconfiguredtoobtainsecuritysettingsfromaMicrosoftExchangeServerareconsideredtrustedbydefault.Thisimpliesthattheadd-insthatrunonclientsthatarenotExchangeclientsandtheadd-insthatusedefaultsecurityinExchangeenvironmentsaretrustedautomatically.AsinOutlook2002,OfficeOutlook2003trustsonlythemainApplicationobjectthatispassedtotheOnConnectioneventoftheadd-in.
COMAdd-insUsingSecuritySettingsfromanExchangeServer
TherehasbeennochangeinthewayOfficeOutlook2003trustsCOMadd-insinanExchangeenvironmentwhenthesecuritysettingsareobtainedfromtheExchangeserver.Anadd-inwillbeconsideredtrustedonlyifit’sregisteredintheSecuritySettingsfolder.Again,asinOutlook2002,OfficeOutlook2003trustsonlythemainApplicationobjectthatispassedtotheOnConnectioneventoftheadd-in.
ImprovementstoOutlookObjectModelGuardandtheImpact
OfficeOutlook2003inheritstheOutlook2002objectmodelguardbehaviorand,inaddition,blockscodethatattemptstoaccesstheBodyandHTMLBodypropertiesofvariousOutlookitems.Thisallowsuserstoverifythattheprogramoradd-inaccessingtheBodyandHTMLBodypropertiesoftheseitemsistrustworthy,beforetheyallowaccesstothecontentsoftheitems.AlthoughthischangeforcesthedisplayofsecuritywarningsinexistingCOMadd-insthataccesstheBodyorHTMLBodypropertiesofitems,thiswillhelppreventmaliciouscodefromrunningunknowntotheuser.
Youcanavoidthedisplayofsecuritywarningsbyderivingallobjects,properties,andmethodsfromtheApplicationobjectpassedtotheOnConnectionprocedureoftheadd-in.OfficeOutlook2003trustsonlythe
Page 25
ApplicationobjectpassedtotheOnConnectionprocedureoftheadd-in.IfyoucreateanewApplicationobject--forexample,byusingtheCreateObjectmethod--thatobjectandanyofitssubordinateobjects,properties,andmethodswillnotbetrustedandtheblockedpropertiesandmethodswillraisesecuritywarnings.
NewObjectModelBlocksinOfficeOutlook2003
ThefollowingaretheadditionalpropertiesthathavebeenblockedinOfficeOutlook2003:
TheIMAddresspropertyofaContactItemobject.TheHTMLBodypropertyofaMailItemobject.TheBodypropertyofthefollowingobjects:ContactItem,MailItem,PostItem,AppointmentItem,TaskItem,TaskRequestItem,TaskRequestAcceptItem,TaskRequestDeclineItem,TaskRequestUpdateItem,DistListItem,JournalItem,MeetingItem,ReportItem,RemoteItem,NoteItem,orDocumentItem.
Also,ifyouuseathird-partyadd-ins,customsolutions,orotherprogramsthatintegratewithOfficeOutlook2003,youmayreceiveoneormoreofthefollowingwarnings:
"Aprogramistryingtoautomaticallysende-mailonyourbehalf.Doyouwanttoallowthis?Ifyouunexpectedlyreceivethismessage,itmaybecausedbyavirus,andyoushouldchooseNo.""Aprogramistryingtoaccesse-mailaddressesyouhavestoredinOutlook.Doyouwanttoallowthis?Ifyouunexpectedlyreceivethismessage,itmaybecausedbyavirus,andyoushouldchooseNo."
ThesewarningmessagesarecommonlyassociatedwithsoftwarethatisdesignedtosynchronizeOutlookdatawithhandheldcomputers,butmayoccurwithanytypeofadd-inorcustomsolution.
Page 26
AnswerWizardFilesCollectionObjectAnswerWizard AnswerWizardFiles
Someofthecontentinthistopicmaynotbeapplicabletosomelanguages.
AcollectionofreferencestoAnswerWizardfiles.TheAnswerWizardFilescollectioncontainsalloftheAnswerWizardfiles(withthefilenameextension.AW)availabletotheactiveMicrosoftOfficeapplication.
Page 27
UsingtheAnswerWizardFilesCollection
UsetheFilespropertytogetthecollectionofAnswerWizardfilereferences.TheFilespropertyreturnsacollectionofstringsthatreferto.AWfiles.ThefollowingexamplereturnstheAnswerWizardFilescollectionanddisplaysthefilecountinamessagebox.
DimcustomAnswerWizardFilesAsAnswerWizardFiles
SetcustomAnswerWizardFiles=Application.AnswerWizard.Files
MsgBoxcustomAnswerWizardFiles.Count
UsetheAddmethodtomakeadditionalfilesavailabletothecurrentAnswerWizard.ThefollowingexampleaddsthefileCustom_1.awtothelistofAnswerWizardfilesintheactiveOfficeapplication.
DimcustomAnswerWizardAsAnswerWizard
SetcustomAnswerWizard=Application.AnswerWizard
customAnswerWizard.Files.Add("c:\awfiles\custom_1.aw")
UsetheItempropertytogetthenameofanexistingAnswerWizardfilereference.ThefollowingexampledisplaysamessageboxcontainingthenameofthefilereferredtobyItem(1).
MsgBoxcustomAnswerWizard.Files.Item(1)
Page 28
BalloonCheckBoxesCollectionObjectBalloonCheckboxes
AcollectionofBalloonCheckBoxobjectsthatrepresentallthecheckboxesintheOfficeAssistantballoon.
Page 29
UsingtheBalloonCheckBoxesCollection
UsetheCheckBoxespropertytoreturntheBalloonCheckBoxescollection.
UseCheckBoxes(index),whereindexisanumberfrom1through5,toreturnasingleBalloonCheckBoxobject.Youcanspecifyuptofivecheckboxes(andfivelabels)perballoon;eachcheckboxappearswhenavalueisassignedtoitsTextproperty.Ifyouspecifymorethanfivecheckboxes,arun-timeerroroccurs.
Thefollowingexamplecreatesaballoonwithaheading,text,andthreeregionchoices.WhentheuserselectsoneormorecheckboxesandthenclicksOK,thespecifiedprocedureorproceduresarecalled.
WithAssistant.NewBalloon
.Heading="RegionalSalesData"
.Text="Selectyourregion"
Fori=1To3
.CheckBoxes(i).Text="Region"&i
Next
.Button=msoButtonSetOkCancel
.Show
If.CheckBoxes(1).CheckedThen
runregion1
EndIf
If.CheckBoxes(2).CheckedThen
runregion2
EndIf
If.CheckBoxes(3).CheckedThen
runregion3
EndIf
EndWith
YoucannotaddcheckboxestoorremovecheckboxesfromtheBalloonCheckBoxescollectionaftertheballoonhasbeendisplayed.
Page 30
Remarks
Ballooncheckboxesdisplaytheuser'schoicesuntiltheuserdismissestheballoon.YoucanuseballoonlabelsinconjunctionwiththeSelectmethodtoreturnanumbercorrespondingtotheuser'schoiceofcheckboxesassoonastheuserclicksthebuttonbesidethelabel.TopassvaluestotheSelectmethodbasedontheuser'schoice,youmusthavetheballoontypesettomsoBalloonTypeButtons.
Page 31
BalloonLabelsCollectionObjectBalloonLabels BalloonLabel
AcollectionofBalloonLabelobjectsthatrepresentallthelabelsintheOfficeAssistantballoon.
Page 32
UsingtheBalloonLabelsCollection
UsetheLabelspropertytoreturntheBalloonLabelscollection.
UseLabels(index),whereindexisanumberfrom1through5,toreturnaBalloonLabelobject.Youcanspecifyuptofivelabels(andfivecheckboxes)perballoon;eachlabelappearswhenavalueisassisgnedtoitsTextproperty.Ifyouspecifymorethanfivelabels,arun-timeerroroccurs.
Thefollowingexamplecreatesaballooncontainingthreechoices.ThevariablereturnValueissettothereturnvalueoftheShowmethod,whichwillbe1,2,or3,correspondingtothelabeltheuserclicks.TheexamplereturnsthevalueofthevariablereturnValue,whichyoucaneitherpasstoanotherprocedureoruseinaSelectCasestatement.
Setb=Assistant.NewBalloon
Withb
.Heading="Thisismyheading"
.Text="Selectoneofthesethings:"
.Labels(1).Text="ChoiceOne"
.Labels(2).Text="ChoiceTwo"
.Labels(3).Text="ChoiceThree"
returnValue=.Show
EndWith
Page 33
Remarks
Ballooncheckboxesdisplaytheuser'schoicesuntiltheuserdismissestheballoon.Youcanuseballoonlabelstoreturnanumbercorrespondingtotheuser'schoiceintheSelectmethodassoonastheuserclicksthebuttonbesidethelabel.TopassvaluestotheSelectmethodbasedontheuser'schoice,youmusthavetheballoontypesettomsoBalloonTypeButtons.
Page 34
COMAddInsCollectionObjectCOMAddIns COMAddIn
AcollectionofCOMAddInobjectsthatprovideinformationaboutaCOMadd-inregisteredintheWindowsregistry.
Page 35
UsingtheCOMAddInsCollection
UsetheCOMAddInspropertyoftheApplicationobjecttoreturntheCOMAddInscollectionforaMicrosoftOfficehostapplication.ThiscollectioncontainsalloftheCOMadd-insthatareavailabletoagivenOfficehostapplication,andtheCountpropertyoftheCOMAddinscollectionreturnsthenumberofavailableCOMadd-ins,asinthefollowingexample.
MsgBoxApplication.COMAddIns.Count
UsetheUpdatemethodoftheCOMAddinscollectiontorefreshthelistofCOMadd-insfromtheWindowsregistry,asinthefollowingexample.
Application.COMAddIns.Update
UseCOMAddIns.Item(index),whereindexiseitheranordinalvaluethatreturnstheCOMadd-inatthatpositionintheCOMAddInscollection,oraStringvaluethatrepresentstheProgIDofthespecifiedCOMadd-in.ThefollowingexampledisplaysaCOMadd-in’sdescriptiontextandProgID("msodraa9.ShapeSelect")inamessagebox.
MsgBoxApplication.COMAddIns.Item("msodraa9.ShapeSelect").Description
Page 37
CommandBarControlsCollectionObjectMultipleobjects CommandBarControls
Multipleobjects
AcollectionofCommandBarControlobjectsthatrepresentthecommandbarcontrolsonacommandbar.
Page 38
UsingtheCommandBarControlsCollection
UsetheControlspropertytoreturntheCommandBarControlscollection.Thefollowingexamplechangesthecaptionofeverycontrolonthetoolbarnamed"Standard"tothecurrentvalueoftheIdpropertyforthatcontrol.
ForEachctlInCommandBars("Standard").Controls
ctl.Caption=CStr(ctl.Id)
Nextctl
UsetheAddmethodtoaddanewcommandbarcontroltotheCommandBarControlscollection.Thisexampleaddsanew,blankbuttontothecommandbarnamed"Custom."
SetmyBlankBtn=CommandBars("Custom").Controls.Add
UseControls(index),whereindexisthecaptionorindexnumberofacontrol,toreturnaCommandBarControl,CommandBarButton,CommandBarComboBox,orCommandBarPopupobject.Thefollowingexamplecopiesthefirstcontrolfromthecommandbarnamed"Standard"tothecommandbarnamed"Custom."
SetmyCustomBar=CommandBars("Custom")
SetmyControl=CommandBars("Standard").Controls(1)
myControl.CopyBar:=myCustomBar,Before:=1
Page 40
CommandBarsCollectionObjectCommandBars Multipleobjects
AcollectionofCommandBarobjectsthatrepresentthecommandbarsinthecontainerapplication.
Page 41
UsingtheCommandBarsCollection
UsetheCommandBarspropertytoreturntheCommandBarscollection.ThefollowingexampledisplaysintheImmediatewindowboththenameandlocalnameofeachmenubarandtoolbar,anditdisplaysavaluethatindicateswhetherthemenubarortoolbarisvisible.
ForEachcbarinCommandBars
Debug.Printcbar.Name,cbar.NameLocal,cbar.Visible
Next
UsetheAddmethodtoaddanewcommandbartothecollection.Thefollowingexamplecreatesacustomtoolbarnamed"Custom1"anddisplaysitasafloatingtoolbar.
Setcbar1=CommandBars.Add(Name:="Custom1",Position:=msoBarFloating)
cbar1.Visible=True
UseCommandBars(index),whereindexisthenameorindexnumberofacommandbar,toreturnasingleCommandBarobject.Thefollowingexampledocksthetoolbarnamed"Custom1"atthebottomoftheapplicationwindow.
CommandBars("Custom1").Position=msoBarBottom
NoteYoucanusethenameorindexnumbertospecifyamenubarortoolbarinthelistofavailablemenubarsandtoolbarsinthecontainerapplication.However,youmustusethenametospecifyamenu,shortcutmenu,orsubmenu(allofwhicharerepresentedbyCommandBarobjects).
Iftwoormorecustommenusorsubmenushavethesamename,CommandBars(index)returnsthefirstone.Toensurethatyoureturnthecorrectmenuorsubmenu,locatethepop-upcontrolthatdisplaysthatmenu.ThenapplytheCommandBarpropertytothepop-upcontroltoreturnthecommandbarthatrepresentsthatmenu.
Page 43
DocumentLibraryVersionsCollectionDocumentLibraryVersions DocumentLibraryVersion
TheDocumentLibraryVersionspropertyoftheMicrosoftOfficeWord2003Document,theMicrosoftOfficeExcel2003Workbook,andtheMicrosoftOfficePowerPoint2003PresentationobjectsreturnsaDocumentLibraryVersionsobject.TheDocumentLibraryVersionsobjectrepresentsacollectionofDocumentLibraryVersionobjects.
Page 44
UsingtheDocumentLibraryVersionsCollection
UsetheDocumentLibraryVersionsobjectwithdocumentsstoredinaWindowsSharePointServicesdocumentlibraryontheservertodeterminewhetherversioningisenabledfortheactivedocumentand,ifversioningisenabled,tomanagethedocument'scollectionofDocumentLibraryVersionobjects.
EachDocumentLibraryVersionobjectrepresentsonesavedversionoftheactivedocument.Whenversioningisenabled,anewversioniscreatedontheserverwhentheactionslistedbelowoccur;additionalversionsarenotcreatedeachtimetheusersaveschangestotheopendocument.
CheckInSave-Anewversioniscreatedontheserverwhentheuserfirstsavesthedocumentafteropeningit.Additionalchangessavedwhilethedocumentisopenapplytothesameversion.RestoreUpload
TheDocumentLibraryVersionsobjectmodelisavailablewhetherversioningisenabledordisabledontheactivedocument.TheDocumentLibraryVersionspropertyoftheDocument,WorkbookandPresentationobjectsdoesnotreturnNothingwhentheactivedocumentisnotstoredinadocumentlibraryorversioningisnotenabled.UsetheIsVersioningEnabledpropertytodeterminewhetherthedocumentlibraryisconfiguredtosaveabackupcopy,orversion,eachtimethedocumentiseditedonthewebsite.
Page 45
Example
Thefollowingexamplecheckstoseewhetherversioningisenabledfortheactivedocumentand,ifso,displaysinformationabouteachsavedversion.
DimdlvVersionsAsOffice.DocumentLibraryVersions
DimdlvVersionAsOffice.DocumentLibraryVersion
DimstrVersionInfoAsString
SetdlvVersions=ActiveDocument.DocumentLibraryVersions
IfdlvVersions.IsVersioningEnabledThen
strVersionInfo="Thisdocumenthas"&_
dlvVersions.Count&"versions:"&vbCrLf
ForEachdlvVersionIndlvVersions
strVersionInfo=strVersionInfo&_
"-Version#:"&dlvVersion.Index&vbCrLf&_
"-Modifiedby:"&dlvVersion.ModifiedBy&vbCrLf&_
"-Modifiedon:"&dlvVersion.Modified&vbCrLf&_
"-Comments:"&dlvVersion.Comments&vbCrLf
Next
Else
strVersionInfo="Versioningnotenabledforthisdocument."
EndIf
MsgBoxstrVersionInfo,vbInformation+vbOKOnly,"VersionInformation"
SetdlvVersion=Nothing
SetdlvVersions=Nothing
Page 46
DocumentPropertiesCollectionObjectAcollectionofDocumentPropertyobjects.EachDocumentPropertyobjectrepresentsabuilt-inorcustompropertyofacontainerdocument.
Page 47
UsingtheDocumentPropertiesCollection
UsetheAddmethodtocreateanewcustompropertyandaddittotheDocumentPropertiescollection.YoucannotusetheAddmethodtocreateabuilt-indocumentproperty.
UseBuiltinDocumentProperties(index),whereindexistheindexnumberofthebuilt-indocumentproperty,toreturnasingleDocumentPropertyobjectthatrepresentsaspecificbuilt-indocumentproperty.UseCustomDocumentProperties(index),whereindexisthenumberofthecustomdocumentproperty,toreturnaDocumentPropertyobjectthatrepresentsaspecificcustomdocumentproperty.
Page 48
FileDialogFiltersCollectionFileDialog FileDialogFilters
FileDialogFilter
AcollectionofFileDialogFilterobjectsthatrepresentthetypesoffilesthatcanbeselectedinafiledialogboxthatisdisplayedusingtheFileDialogobject.
Page 49
UsingtheFileDialogFilterscollection
UsetheFilterspropertyoftheFileDialogobjecttoreturnaFileDialogFilterscollection.ThefollowingcodereturnstheFileDialogFilterscollectionfortheFileOpendialogbox.
Application.FileDialog(msoFileDialogOpen).Filters
UsetheAddmethodtoaddFileDialogFilterobjectstotheFileDialogFilterscollection.ThefollowingexampleusestheClearmethodtoclearthecollectionandthenaddsfilterstothecollection.TheClearmethodcompletelyemptiesthecollection;however,ifyoudon'taddanyfilterstothecollectionafteryouclearit,the"Allfiles(*.*)"filterisaddedautomatically.
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'ChangethecontentsoftheFilesofTypelist.
'EmptythelistbyclearingtheFileDialogFilterscollection.
.Filters.Clear
'Addafilterthatincludesallfiles.
.Filters.Add"Allfiles","*.*"
'AddafilterthatincludesGIFandJPEGimagesandmakeitthefirstiteminthelist.
.Filters.Add"Images","*.gif;*.jpg;*.jpeg",1
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Theuserpressedtheactionbutton.
If.Show=-1Then
Page 50
'StepthrougheachStringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Pathname:"&vrtSelectedItem
NextvrtSelectedItem
'TheuserpressedCancel.
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Setfd=Nothing
EndSub
WhenchangingtheFileDialogFilterscollection,rememberthateachapplicationcanonlyinstantiateasingleFileDialogobject.ThismeansthattheFileDialogFilterscollectionwillresettoitsdefaultfilterswheneveryoucalltheFileDialogmethodwithanewdialogboxtype.
ThefollowingexampleiteratesthroughthedefaultfiltersoftheSaveAsdialogboxanddisplaysthedescriptionofeachfilterthatincludesaMicrosoftExcelfile.
SubMain()
'DeclareavariableasaFileDialogFilterscollection.
DimfdfsAsFileDialogFilters
'DeclareavariableasaFileDialogFilterobject.
DimfdfAsFileDialogFilter
'SettheFileDialogFilterscollectionvariableto
'theFileDialogFilterscollectionoftheSaveAsdialogbox.
Setfdfs=Application.FileDialog(msoFileDialogSaveAs).Filters
'Iteratethroughthedescriptionandextensionsofeach
'defaultfilterintheSaveAsdialogbox.
ForEachfdfInfdfs
'Displaythedescriptionoffiltersthatinclude
Page 51
'MicrosoftExcelfiles
IfInStr(1,fdf.Extensions,"xls",vbTextCompare)>0Then
MsgBox"Descriptionoffilter:"&fdf.Description
EndIf
Nextfdf
EndSub
NoteArun-timeerrorwilloccuriftheFilterspropertyisusedinconjunctionwiththeClear,Add,orDeletemethodswhenappliedtoaSaveAsFileDiaogobject.Forexample,Application.FileDialog(msoFileDialogSaveAs).Filters.Clearwillresultinarun-timeerror.
Page 52
FileDialogSelectedItemsCollectionFileDialog FileDialogSelectedItems
AcollectionofStringvaluesthatcorrespondtothepathsofthefilesorfoldersthatauserhasselectedfromafiledialogboxdisplayedthroughtheFileDialogobject.
Page 53
UsingtheFileDialogSelectedItemscollection
UsetheSelectedItemspropertywiththeFileDialogobjecttoreturnaFileDialogSelectedItemscollection.ThefollowingexampledisplaysaFilePickerdialogboxanddisplayseachselectedfileinamessagebox.
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'Allowtheselectionofmultiplefile.
.AllowMultiSelect=True
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Theuserpressedtheactionbutton.
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Selecteditem'spath:"&vrtSelectedItem
NextvrtSelectedItem
'TheuserpressedCancel.
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Setfd=Nothing
Page 55
FileTypesCollectionFileSearch FileTypes
AcollectionofvaluesofthetypemsoFileTypethatdeterminewhichtypesoffilesarereturnedbytheExecutemethodoftheFileSearchobject.
Page 56
UsingtheFileTypescollection
UsetheFileTypespropertywiththeFileSearchobjecttoreturnaFileTypescollection;forexample:
Setft=Application.FileSearch.FileTypes
NoteTheFileTypepropertyoftheFileSearchobjectclearstheFileTypescollectionandsetsthefirstiteminthecollectiontothefiletypedefinedbytheFileTypeproperty.
ThereisonlyoneFileTypescollectionforallsearchessoit'simportanttocleartheFileTypescollectionbeforeexecutingasearchunlessyouwishtosearchforfiletypesfromprevioussearches.TheeasiestwaytoclearthecollectionistosettheFileTypepropertytothefirstfiletypeforwhichyouwanttosearch.YoucanalsoremoveindividualtypesusingtheRemovemethod.Todeterminethefiletypeofeachiteminthecollection,usetheItemmethodtoreturnthemsoFileTypevalue.
ThefollowingexamplesearchesforallHTMLandMicrosoftExcelfilesontheC:\drive.
SubSearchForFiles()
'Declareavariabletoactasagenericcounter
DimlngCountAsLong
'UseaWith...EndWithblocktoreferencethe
'FileSearchobject
WithApplication.FileSearch
'Clearalltheparametersoftheprevioussearches.
'Thismethoddoesn'tcleartheLookInpropertyor
'theSearchFolderscollection.
.NewSearch
'SettingtheFileTypepropertyclearsthe
'FileTypescollectionandsetsthefirst
'iteminthecollectiontothefiletype
'definedbytheFileTypeproperty.
.FileType=msoFileTypeWebPages
Page 57
'AddaseconditemtotheFileTypescollection
.FileTypes.AddmsoFileTypeExcelWorkbooks
'DisplaythenumberofFileTypesinthecollection.
MsgBox"Youareabouttosearchfor"&.FileTypes.Count&_
"filetypes."
'SetupthesearchtolookinallsubfoldersontheC:\drive.
.LookIn="C:\"
.SearchSubFolders=True
'Executethesearchandtesttoseeifanyfiles
'werefound.
If.Execute<>0Then
'Displaythenumberoffilesfound.
MsgBox"Filesfound:"&.FoundFiles.Count
'Loopthroughthelistoffoundfilesand
'displaythepathofeachoneinamessagebox.
ForlngCount=1To.FoundFiles.Count
IfMsgBox(.FoundFiles.Item(lngCount),vbOKCancel,_
"Foundfiles")=vbCancelThen
'Breakoutoftheloop
lngCount=.FoundFiles.Count
EndIf
NextlngCount
Else
MsgBox"Nofilesfound."
EndIf
EndWith
EndSub
ThefollowingexampleloopsthroughtheFileTypescollectionandremovesanyfiletypesthataren'tMicrosoftWordorMicrosoftExcelfiles(ingeneral,it'ssimplertocleartheFileTypescollectionandstartfromscratch).
SubRemoveFileTypeFromCollection()
'Defineanintegertouseasacounter
'wheniteratingthroughtheFileTypescollection.
DimintFileIndexAsInteger
'UseaWith...EndWithblocktoreferencetheFileSearchobject.
WithApplication.FileSearch
Page 58
'LoopthroughalloftheitemsintheFileTypescollection.
intFileIndex=1
DoWhileintFileIndex<=.FileTypes.Count
SelectCase.FileTypes.Item(intFileIndex)
CasemsoFileTypeWordDocuments,msoFileTypeExcelWorkbooks
CaseElse
'Ifthefiletypeisn'taMicrosoftWordor
'MicrosoftExcelfile,removeit.
.FileTypes.RemoveintFileIndex
'Decrementthecountersothatnofiletypesaremissed.
intFileIndex=intFileIndex-1
EndSelect
'Incrementthecountertotestthenextfiletype.
intFileIndex=intFileIndex+1
Loop
EndWith
EndSub
Page 59
FoundFilesObjectFileSearch FoundFiles
Representsthelistoffilesreturnedfromafilesearch.
Page 60
UsingtheFoundFilesObject
UsetheFoundFilespropertytoreturntheFoundFilesobject.Thisexamplestepsthroughthelistoffilesthatarefoundanddisplaysthepathandfilenameofeachfile.UseFoundFiles(index),whereindexistheindexnumber,toreturnthepathandfilenameofaspecificfilefoundduringthesearch.
WithApplication.FileSearch
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
NextI
EndWith
UsetheExecutemethodtobeginthefilesearchandupdatetheFoundFilesobject.ThefollowingexamplesearchestheMyDocumentsfolderforallfileswhosenamesbeginwith"Cmd"anddisplaysthenameandlocationofeachfilethat'sfound.Theexamplealsosortsthereturnedfilesinascendingalphabeticorderbyfilename.
Setfs=Application.FileSearch
Withfs
.LookIn="C:\MyDocuments"
.FileName="cmd*"
If.Execute(SortBy:=msoSortbyFileName,_
SortOrder:=msoSortOrderAscending)>0Then
MsgBox"Therewere"&.FoundFiles.Count&_
"file(s)found."
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
Nexti
Else
MsgBox"Therewerenofilesfound."
EndIf
EndWith
Page 62
HTMLProjectItemsCollectionHTMLProject HTMLProjectItems
HTMLProjectItem
AcollectionofHTMLProjectItemobjectsthatrepresenttheHTMLprojectitemscontainedintheHTMLProjectobject.
Page 63
UsingtheHTMLProjectItemsCollection
UsetheHTMLProjectItemspropertyoftheHTMLProjectobjecttoreturntheHTMLProjectItemscollection.UsetheCountpropertyoftheHTMLProjectItemscollectiontoreturnthenumberofprojectitemsintheHTMLprojectforthespecifieddocument.UsetheItemmethodoftheHTMLProjectItemscollectiontoreturnanindividualprojectitem.ThefollowingexamplereturnsthenameofthefirstprojectitemintheHTMLProjectItemscollectionfortheactivedocument.
MsgBox"Thefirstitemis"&_
ActiveDocument.HTMLProject.HTMLProjectItems(1).Name
Page 64
ODSOColumnsObjectODSOColumns ODSOColumn
AcollectionofODSOColumnobjectsthatrepresentthedatafieldsinamailmergedatasource.
Page 65
UsingtheODSOColumnsobject
UsetheColumnspropertytoreturntheODSOColumnscollection.Thefollowingexampledisplaysthefieldnamesinthedatasourceattachedtotheactivepublication.
SubShowFieldNames()
DimappOfficeAsOfficeDataSourceObject
DimintCountAsInteger
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Columns
ForintCount=1To.Count
MsgBox"ColumnName:"&.Item(intCount).Name
Next
EndWith
EndSub
UseColumns(index),whereindexisthedatafieldnameortheindexnumber,toreturnasingleODSOColumnobject.Theindexnumberrepresentsthepositionofthedatafieldinthemailmergedatasource.ThisexampleretrievesthenameofthefirstfieldandvalueofthefirstrecordoftheFirstNamefieldinthedatasourceattachedtotheactivepublication.
SubGetDataFromSource()
DimappOfficeAsOfficeDataSourceObject
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Columns
MsgBox"FieldName:"&.Columns(1).Name&_
"Value:"&.Columns("FirstName").Value
EndWith
EndSub
Page 67
ODSOFiltersObjectODSOFilters ODSOFilter
Representsallthefilterstoapplytothedatasourceattachedtothemailmergepublication.TheODSOFiltersobjectiscomprisedofODSOFilterobjects.
Page 68
UsingtheODSOFiltersobject
UsetheAddmethodoftheODSOFiltersobjecttoaddanewfiltercriteriontothequery.Thisexampleaddsanewlinetothequerystringandthenappliesthecombinedfiltertothedatasource.
SubSetQueryCriterion()
DimappOfficeAsOfficeDataSourceObject
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Filters
.AddColumn:="Region",_
Comparison:=msoFilterComparisonIsBlank,_
Conjunction:=msoFilterConjunctionAnd
.ApplyFilter
EndWith
EndSub
UsetheItemmethodtoaccessanindividualfiltercriterion.Thisexampleloopsthroughallthefiltercriterionandifitfindsonewithavalueof"Region",changesittoremovefromthemailmergeallrecordsthatarenotequalto"WA".
SubSetQueryCriterion()
DimappOfficeAsOffice.OfficeDataSourceObject
DimintItemAsInteger
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Filters
ForintItem=1To.Count
With.Item(intItem)
If.Column="Region"Then
.Comparison=msoFilterComparisonNotEqual
.CompareTo="WA"
If.Conjunction="Or"Then.Conjunction="And"
EndIf
EndWith
NextintItem
EndWith
Page 70
PropertyTestsCollectionObjectFileSearch PropertyTests
PropertyTest
AcollectionofPropertyTestobjectsthatrepresentallthesearchcriteriaofafilesearch.SearchcriteriaarelistedintheAdvancedFinddialogbox(Filemenu,Opencommand,AdvancedFindbutton).
Page 71
UsingthePropertyTestsCollection
UsethePropertyTestspropertytoreturnthePropertyTestscollection.Thefollowingexampledisplaysthenumberofadvanced-findsearchcriteriathatwillbeusedforonefilesearch.
Application.FileSearch.PropertyTests.Count
UsetheAddmethodtoaddanewPropertyTestobjecttothePropertyTestscollection.Thefollowingexampleaddstwopropertyteststothesearchcriteria.Thefirstcriterionspecifiesthatthefilesthatarefoundcanbeofanyfiletype,andthesecondcriterionspecifiesthatthesefilesmusthavebeenmodifiedbetweenJanuary1,1996,andJune30,1996.Theexampledisplaysthenumberoffilesfoundanddisplaysthenameofeachfileinamessagebox.
Setfs=Application.FileSearch
fs.NewSearch
Withfs.PropertyTests
.AddName:="FilesofType",_
Condition:=msoConditionFileTypeAllFiles,_
Connector:=msoConnectorOr
.AddName:="LastModified",_
Condition:=msoConditionAnytimeBetween,_
Value:="1/1/96",SecondValue:="6/1/96",_
Connector:=msoConnectorAnd
EndWith
Iffs.Execute()>0Then
MsgBox"Therewere"&fs.FoundFiles.Count&_
"file(s)found."
Fori=1Tofs.FoundFiles.Count
MsgBoxfs.FoundFiles(i)
Nexti
Else
MsgBox"Therewerenofilesfound."
EndIf
UsePropertyTests(index),whereindexistheindexnumber,toreturnasinglePropertyTestobject.ThefollowingexampledisplaysallthesearchcriteriaforthefirstpropertytestinthePropertyTestscollection.
WithApplication.FileSearch.PropertyTests(1)
Page 72
myString="Thisisthesearchcriteria:"_
&"Thenameis:"&.Name&".Theconditionis:"_
&.Condition
If.Value<>""Then
myString=myString&".Thevalueis:"&.Value
If.SecondValue<>""Then
myString=myString_
&".Thesecondvalueis:"_
&.SecondValue&",andtheconnectoris"_
&.Connector
EndIf
EndIf
MsgBoxmyString
EndWith
Page 73
ScopeFoldersCollectionScopeFolder ScopeFolders
ScopeFolderScopeFolders
AcollectionofScopeFolderobjects.OnlyScopeFolderobjectscontainScopeFolderscollections.EachScopeFolderscollectioncontainstheScopeFolderobjectsthatcorrespondtothesubfoldersoftheparentScopeFolderobject.
Page 74
UsingtheScopeFolderscollection
UsetheScopeFolderspropertyoftheScopeFolderobjecttoreturnaScopeFolderscollection.
DimsfsasScopeFolders
Setsfs=Application.FileSearch.SearchScopes.Item(1).ScopeFolder.ScopeFolders
Youcan'taddorremoveScopeFolderobjectsfromaScopeFolderscollection.
Page 75
ScriptsCollectionObjectScripts Script
AcollectionofScriptobjectsthatrepresentthecollectionofHTMLscriptsinthespecifieddocument.
Page 76
UsingtheScriptsCollection
TheScriptscollectioncontainsalloftheScriptobjectsinagivendocument,insourceorder(theorderinwhichScriptobjectswereaddedtothesourcefile).Sourceorderisn’taffectedbythelocation(headerorbodytext)ofthescriptinthedocument.TheScriptscollectioncanbeaccessedbyusingtheScriptspropertyoftheappropriateobject(forexample,theDocumentobjectinMicrosoftWord).
YoucanuseScriptobjectstoaccessascriptortoaddascripttoaMicrosoftWorddocument,aMicrosoftExcelworksheet,oraMicrosoftPowerPointslide.YoucanalsousetheScriptscollectiontoaccessanyHTMLpageorscriptthat’sopenedinaMicrosoftOfficeapplication.
NoteMicrosoftAccessdoesn’tusethissharedOfficecomponent.
Page 77
AddingaScript
WhenyouaddaScriptobjecttotheScriptscollection,aShapeobjectoftypemsoScriptAnchorisautomaticallyaddedtothedocument.OnanExcelworksheetoraPowerPointslide,theshapeisaddedtotheShapescollection;inaWordDocument,theshapeisaddedtotheInlineShapescollection.YouaddaScripttoadocumentbyusingtheAddmethod.ThefollowingexampleaddsasimplescripttotheactiveWorddocument.
myScript=ActiveDocument.Scripts.Add(_
,msoScriptLocationInBody,_
msoScriptLanguageVisualBasic,_
"ScriptOne",,_
"MsgBox""ThisisScriptOne.""")
ToaccessaparticularitemintheScriptscollection,usetheItemmethod,andsupplyeithertheIDattributeofthe<SCRIPT>tagortheindexnumberthatindicatesthepositionofthescriptinthecollection.TheIDmustbeuniquewithinthedocument.InthecaseofduplicateIDattributes,thefirstscriptfoundthathasthatIDisreturned.ThefollowingexampledisplaysamessageboxindicatingthelanguageofthefirstscriptfoundthatusestheID"ScriptOne".
MsgBox(ActiveDocument.Scripts.Item("ScriptOne").Language)
UsetheCountpropertytodeterminethenumberofScriptobjectsinthespecifieddocument.Thefollowingexampledisplaysthenumberofscriptsintheactivedocument.
IfActiveDocument.Scripts.Count=0Then
MsgBox("Thereareno"&_
"scriptsinthisdocument.")
EndIf
IfActiveDocument.Scripts.Count=1Then
MsgBox("Thereis"&_
ActiveDocument.Scripts.Count&_
"scriptinthisdocument.")
EndIf
IfActiveDocument.Scripts.Count>1Then
MsgBox("Thereare"&_
ActiveDocument.Scripts.Count&_
Page 78
"scriptsinthisdocument.")
EndIf
UsetheDeletemethodtoremoveascriptfromtheScriptscollection,asinthefollowingexample.
ActiveDocument.Scripts("ScriptOne").Delete
Page 79
SearchFoldersCollectionFileSearch SearchFolders
ScopeFolderScopeFolders
AcollectionofScopeFolderobjectsthatdetermineswhichfoldersaresearchedwhentheExecutemethodoftheFileSearchobjectiscalled.
Page 80
UsingtheSearchFolderscollection
UsetheSearchFolderspropertywiththeFileSearchobjecttoreturntheSearchFolderscollection;forexample:
Setsfs=Application.FileSearch.SearchFolders
ForeachapplicationthereisonlyasingleSearchFolderscollection.Thecontentsofthecollectionremainsafterthecodethatcallsithasfinishedexecuting.Consequently,itisimportanttoclearthecollectionunlessyouwanttoincludefoldersfromprevioussearchesinyoursearch.
YoucanusetheAddmethodoftheSearchFolderscollectiontoaddaScopeFolderobjecttotheSearchFolderscollection,however,itisusuallysimplertousetheAddToSearchFoldersmethodoftheScopeFolderthatyouwanttoadd,asthereisonlyoneSearchFolderscollectionforallsearches.
TheSearchFolderscollectioncanbeseenasacomplimenttotheLookInpropertyoftheFileSearchobject.Bothspecifythefolderstosearchandbothareusedwhenthesearchisexecuted.However,ifyouonlywanttousetheLookInproperty,youshouldmakesurethattheSearchFolderscollectionisempty.Conversely,ifyouonlywanttousetheSearchFolderscollection,settheLookInpropertytothepathofthefirstmemberoftheSearchFolderscollectionbeforeyoucalltheExecutemethod.
Thefollowingexamplesearcheseveryfoldernamed"1033"onthelocalmachineforallHTMLandMicrosoftExcelfiles.TheexamplemakesuseoftheSearchFolderscollection,SearchScopescollection,andScopeFolderscollection.
Thisexampleconsistsoftworoutines.TheSearchEveryFolderroutineistheroutinethatyoushouldrun.TheOutputPathsroutineisseparatefromthemainroutinebecauseitcallsitselfrecursivelyinordertotraversetheentiredirectorystructureofthelocalmachine.
SubSearchEveryFolder()
'Declarevariablesthatreferencea
Page 81
'SearchScopeandaScopeFolderobject.
DimssAsSearchScope
DimsfAsScopeFolder
'Declareavariabletoactasagenericcounter.
DimlngCountAsLong
'UseaWith...EndWithblocktoreferencethe
'FileSearchobject.
WithApplication.FileSearch
'Clearalltheparametersoftheprevioussearches.
'Thismethoddoesn'tcleartheLookInpropertyor
'theSearchFolderscollection.
.NewSearch
'Specifythetypeoffileforwhichtosearch.
'UsetheFileTypepropertytospecifythefirsttype
'andthenaddadditionaltypestotheFileTypescollection.
.FileType=msoFileTypeWebPages
.FileTypes.AddmsoFileTypeExcelWorkbooks
'CleartheSearchFoldercollectionby
'loopingthrougheachScopeFolderobject
'andremovingit.
ForlngCount=1To.SearchFolders.Count
.SearchFolders.RemovelngCount
NextlngCount
'LoopthroughtheSearchScopescollectiontofind
'thescopeinwhichyouwanttosearch.Inthis
'casethescopeisthelocalmachine.
ForEachssIn.SearchScopes
SelectCasess.Type
CasemsoSearchInMyComputer
'LoopthrougheachScopeFolderin
'theScopeFolderscollectionofthe
'SearchScopeobject.
ForEachsfInss.ScopeFolder.ScopeFolders
'Callafunctionthatloopsthroughall
'ofthesubfoldersoftherootScopeFolder.
'Thisfunctionaddsanyfoldersnamed"1033"tothe
'SearchFolderscollection.
CallOutputPaths(sf.ScopeFolders,"1033")
Nextsf
CaseElse
Page 82
EndSelect
Nextss
'TesttoseeifanyScopeFolderscollectionswereaddedto
'theSearchFolderscollection.
If.SearchFolders.Count>0Then
'SettheLookInpropertytothepathof
'thefirstScopeFolderobjectintheSearchFolders
'collection.Thisisheresothatanyprevious
'settingoftheLookInpropertydoesn'taffect
'thesearch.
.LookIn=.SearchFolders.Item(1).Path
'Executethesearchandtesttoseeifanyfiles
'werefound.
If.Execute<>0Then
'Displaythenumberoffilesfound.
MsgBox"Filesfound:"&.FoundFiles.Count
'Loopthroughthelistoffoundfilesand
'displaythepathofeachoneinamessagebox.
ForlngCount=1To.FoundFiles.Count
IfMsgBox(.FoundFiles.Item(lngCount),vbOKCancel,_
"Foundfiles")=vbCancelThen
'Breakoutoftheloop
lngCount=.FoundFiles.Count
EndIf
NextlngCount
EndIf
EndIf
EndWith
EndSub
'ThissubroutineloopsthroughalloftheScopeFolderscollections
'inagivenScopeFolderscollection.Itaddsanyfolder
'thathasthesamenameasthevalueofstrFolder
'totheSearchFolderscollection.
SubOutputPaths(ByValsfsAsScopeFolders,_
ByRefstrFolderAsString)
'DeclareavariableasaScopeFolderobject
DimsfAsScopeFolder
'LoopthrougheachScopeFolderobjectinthe
'ScopeFolderscollection.
Page 83
ForEachsfInsfs
'TesttoseeifthefoldernameoftheScopeFolder
'matchesthevalueofstrFolder.UseLCasetoensure
'thatcasedoesnotaffectthematch.
IfLCase(sf.Name)=LCase(strFolder)Then
'AddtheScopeFoldertotheSearchFolderscollection.
sf.AddToSearchFolders
EndIf
'IncludeaDoEventscallbecausethereisthepotentialforthis
'looptolastalongtime.TheDoEventscallallowsthisprocessto
'continuehandlingevents.
DoEvents
'TesttoseeiftheScopeFolderscollectioninthe
'currentScopeFolderisempty.Ifitisn'tempty,then
'thatmeansthatthecurrentScopeFolderobjectcontainssubfolders.
Ifsf.ScopeFolders.Count>0Then
'Thissubroutinerecursivelycallsitselfsothat
'itcanaddthesubfoldersofthecurrentScopeFolderobject
'totheSearchFolderscollection.
CallOutputPaths(sf.ScopeFolders,strFolder)
EndIf
Nextsf
EndSub
Page 84
SearchScopesCollectionFileSearch SearchScopes
SearchScopeScopeFolder
AcollectionofSearchScopeobjects.
Page 85
UsingtheSearchScopescollection
UsetheSearchScopespropertyoftheFileSearchobjecttoreturnaSearchScopescollection;forexample:
DimsssAsSearchScopes
Setsss=Application.FileSearch.SearchScopes
Youcan'taddorremoveSearchScopeobjectsfromtheSearchScopescollection.
Page 86
SharedWorkspaceFilesCollectionSharedWorkspace SharedWorkspaceFiles
SharedWorkspaceFile
AcollectionoftheSharedWorkspaceFileobjectsinthecurrentsharedworkspace.
Page 87
UsingtheSharedWorkspaceFilesCollection
UsetheFilespropertyoftheSharedWorkspaceobjecttoreturnaSharedWorkspaceFilescollection.
DimswsFilesAsOffice.SharedWorkspaceFiles
SetswsFiles=ActiveWorkbook.SharedWorkspace.Files
MsgBox"Thereare"&swsFiles.Count&_
"file(s)
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsFiles=Nothing
Page 88
SharedWorkspaceFoldersCollectionSharedWorkspace SharedWorkspaceFolders
SharedWorkspaceFolder
AcollectionoftheSharedWorkspaceFolderobjectsinthecurrentsharedworkspace.
Page 89
UsingtheSharedWorkspaceFoldersCollection
UsetheFolderspropertyoftheSharedWorkspaceobjecttoreturnaSharedWorkspaceFolderscollection.
DimswsFoldersAsOffice.SharedWorkspaceFolders
SetswsFolders=ActiveWorkbook.SharedWorkspace.Folders
MsgBox"Thereare"&swsFolders.Count&_
"folder(s)inthecurrentsharedworkspace.",_
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsFolders=Nothing
Page 90
SharedWorkspaceLinksCollectionSharedWorkspace SharedWorkspaceLinks
SharedWorkspaceLink
AcollectionoftheSharedWorkspaceLinkobjectsinthecurrentsharedworkspace.
Page 91
UsingtheSharedWorkspaceLinksCollection
UsetheLinkspropertyoftheSharedWorkspaceobjecttoreturnaSharedWorkspaceLinkscollection.
DimswsLinksAsOffice.SharedWorkspaceLinks
SetswsLinks=ActiveWorkbook.SharedWorkspace.Links
MsgBox"Thereare"&swsLinks.Count&_
"link(s)inthecurrentsharedworkspace.",_
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsLinks=Nothing
Page 92
SharedWorkspaceMembersCollectionSharedWorkspace SharedWorkspaceMembers
SharedWorkspaceMember
AcollectionoftheSharedWorkspaceMemberobjectsinthecurrentsharedworkspace.
Page 93
UsingtheSharedWorkspaceMembersCollection
UsetheMemberspropertyoftheSharedWorkspaceobjecttoreturnaSharedWorkspaceMemberscollection.
DimswsMembersAsOffice.SharedWorkspaceMembers
SetswsMembers=ActiveWorkbook.SharedWorkspace.Members
MsgBox"Thereare"&swsMembers.Count&_
"member(s)inthecurrentsharedworkspace.",_
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsMembers=Nothing
Page 94
SharedWorkspaceTasksCollectionSharedWorkspace SharedWorkspaceTasks
SharedWorkspaceTask
AcollectionoftheSharedWorkspaceTaskobjectsinthecurrentsharedworkspace.
Page 95
UsingtheSharedWorkspaceTasksCollection
UsetheTaskspropertyoftheSharedWorkspaceobjecttoreturnaSharedWorkspaceTaskscollection.
DimswsTasksAsOffice.SharedWorkspaceTasks
SetswsTasks=ActiveWorkbook.SharedWorkspace.Tasks
MsgBox"Thereare"&swsTasks.Count&_
"task(s)inthecurrentsharedworkspace.",_
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsTasks=Nothing
Page 96
SignatureSetCollectionSignatureSet Signature
AcollectionofSignatureobjectsthatcorrespondtothedigitalsignaturesattachedtoadocument.
Page 97
UsingtheSignatureSetcollection
UsetheSignaturespropertyoftheDocumentobjecttoreturnaSignatureSetcollection;forexample:
Setsigs=ActiveDocument.Signatures
NoteChangesthatyoumaketotheSignatureSetcollectionofadocumentwillnotpersistunlessyoucalltheCommitmethod.
YoucanaddaSignatureobjecttoaSignatureSetcollectionusingtheAddmethodandyoucanreturnanexistingmemberusingtheItemmethod.ToremoveaSignaturefromaSignatureSetcollection,usetheDeletemethodoftheSignatureobject.
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandpassthisfunctionthenameofacertificateissuerandthenameofacertificatesignerthatmatchtheIssuedByandIssuedTofieldsofadigitalcertificateintheDigitalCertificatesdialogbox.Thisexamplewilltesttomakesurethatthedigitalsignaturethattheuserselectsmeetscertaincriteria,suchasnothavingexpired,beforethenewsignatureiscommittedtothedisk.
FunctionAddSignature(ByValstrIssuerAsString,_
strSignerAsString)AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
'TestseveralpropertiesbeforecommittingtheSignatureobjecttodisk.
Ifsig.Issuer=strIssuerAnd_
sig.Signer=strSignerAnd_
Page 98
sig.IsCertificateExpired=FalseAnd_
sig.IsCertificateRevoked=FalseAnd_
sig.IsValid=TrueThen
MsgBox"Signed"
AddSignature=True
'Otherwise,removetheSignatureobjectfromtheSignatureSetcollection.
Else
sig.Delete
MsgBox"Notsigned"
AddSignature=False
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 100
WebPageFontsCollectionObjectWebPageFonts WebPageFont
AcollectionofWebPageFontobjectsthatdescribetheproportionalfont,proportionalfontsize,fixed-widthfont,andfixed-widthfontsizeusedwhendocumentsaresavedasWebpages.YoucanspecifyadifferentsetofWebpagefontpropertiesforeachavailablecharacterset.
Page 101
UsingtheWebPageFontsCollection
TheWebPageFontscollectioncontainsoneWebPageFontobjectforeachcharacterset.
Thefollowingcharactersetsaresupported.msoCharacterSetArabicmsoCharacterSetCyrillicmsoCharacterSetEnglishWesternEuropeanOtherLatinScriptmsoCharacterSetGreekmsoCharacterSetHebrewmsoCharacterSetJapanesemsoCharacterSetKoreanmsoCharacterSetMultilingualUnicodemsoCharacterSetSimplifiedChinesemsoCharacterSetThaimsoCharacterSetTraditionalChinesemsoCharacterSetVietnamese
ThefollowingexampleusestheItempropertytosetmyFonttotheWebPageFontobjectfortheEnglish/WesternEuropean/OtherLatinScriptcharactersetinthecurrentapplication.
DimmyFontAsWebPageFont
SetmyFont=_
Application.DefaultWebOptions.Fonts.Item_
(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)
Page 102
AnswerWizardObjectAnswerWizard AnswerWizardFiles
Someofthecontentinthistopicmaynotbeapplicabletosomelanguages.
RepresentstheAnswerWizardinaMicrosoftOfficeapplication.There’sonlyoneAnswerWizardperapplication,andallchangestotheAnswerWizardortheAnswerWizardFilescollectionaffecttheactiveOfficeapplicationimmediately.
UsingtheAnswerWizardObject
UsetheClearFileListmethodtoremoveallentriesfromthelistoffilesavailabletothecurrentAnswerWizard.UsingthismethodensuresthatthedefaultfilesavailabletotheOfficehostapplicationarenolongeraccessiblethroughtheAnswerWizard,suchaswhenyou’rereplacingtheAnswerWizardfileswithcustom.AWfiles.ThefollowingexampleclearsthefilelistforthedefaultAnswerWizardandthenaddstwofilestothecustomAnswerWizard.
customAnswerWizard.ClearFileList
customAnswerWizard.Files.Add("c:\awfiles\custom_1.aw")
customAnswerWizard.Files.Add("c:\awfiles\custom_2.aw")
UsetheResetFileListmethodtorestorethelistoffilesforthecurrentAnswerWizardtothedefaultlistoffilesfortheOfficehostapplication.YoucanalsoestablishacustomdefaultfilelistintheWindowsregistrybyaddingthenamesofthecustomfilestotheappropriateregistrykey;thefilesspecifiedinthatregistrykeywillthenberestoredwhenResetFileListiscalled.ThisexampleresetsthefilelistforthecurrentAnswerWizard.
customAnswerWizard.ResetFileList
UsetheFilespropertytogetthecollectionofAnswerWizardfilereferences.TheFilespropertyreturnsacollectionofstringsthatreferto.AWfiles.ThefollowingexamplereturnstheAnswerWizardFilescollectionanddisplaysthe
Page 103
filecountinamessagebox.
DimcustomAnswerWizardFilesAsAnswerWizardFiles
SetcustomAnswerWizardFiles=Application.AnswerWizard.Files
MsgBoxcustomAnswerWizardFiles.Count
Page 104
AssistantObjectAssistant Balloon
Someofthecontentinthistopicmaynotbeapplicabletosomelanguages.
RepresentstheMicrosoftOfficeAssistant.
Page 105
UsingtheAssistantObject
UsetheAssistantpropertytoreturntheAssistantobject.Thereisn'tacollectionfortheAssistantobject;onlyoneAssistantobjectcanbeactiveatatime.UsetheVisiblepropertytodisplaytheAssistant,andusetheOnpropertytoenabletheAssistant.
Page 106
Remarks
ThedefaultAssistantisRocky.ToselectadifferentAssistantprogrammatically,usetheFileNameproperty.
ThefollowingexampledisplaysandanimatestheAssistant.
WithAssistant
.Visible=True
.Animation=msoAnimationGreeting
EndWith
Page 107
BalloonObjectAssistant Balloon
RepresentstheballoonwheretheOfficeAssistantdisplaysinformation.Aballooncancontaincontrolssuchascheckboxesandlabels.
Page 108
UsingtheBalloonObject
UsetheNewBalloonpropertytoreturnaBalloonobject.Thereisn'tacollectionfortheBalloonobject;onlyoneballooncanbevisibleatatime.However,it'spossibletodefineseveralballoonsanddisplayanyoneofthemwhenneeded.Formoreinformation,see"DefiningandReusingBalloons"laterinthistopic.
UsetheShowmethodtomakethespecifiedballoonvisible.UsetheCallbackpropertytorunproceduresbasedonselectionsfrommodelessballoons(balloonsthatremainvisiblewhileauserworksintheapplication).UsetheClosemethodtoclosemodelessballoons.
Thefollowingexamplecreatesaballoonthatcontainstipsforsavingentereddata.
WithAssistant.NewBalloon
.BalloonType=msoBalloonTypeBullets
.Icon=msoIconTip
.Button=msoButtonSetOk
.Heading="TipsforSavingInformation."
.Labels(1).Text="Saveyourworkoften."
.Labels(2).Text="Installasurgeprotector."
.Labels(3).Text="Exityourapplicationproperly."
.Show
EndWith
Page 109
DefiningandReusingBalloons
Youcanreuseballoonobjectsyou'vealreadycreatedbyassigningtheobjecttoavariableanddisplayingthevariablewhenyouneedit.Thisexampledefinesballoon1andballoon2separatelysothattheycanbereused.
Setballoon1=Assistant.NewBalloon
balloon1.Heading="Firstballoon"
Setballoon2=Assistant.NewBalloon
balloon2.Heading="Secondballoon"
balloon1.Show
balloon2.Show
balloon1.Heading="Firstballoon,newheading"
balloon1.Show
Alternatively,insteadofusingseparatevariables,youcanplacetheballoonobjectintoanarray.
Page 110
BalloonCheckBoxObjectBalloonCheckbox
RepresentsacheckboxintheOfficeAssistantballoon.TheBalloonCheckBoxobjectisamemberoftheBalloonCheckBoxescollection.
Page 111
UsingtheBalloonCheckBoxObject
UseCheckBoxes(index),whereindexisanumberfrom1through5,toreturnasingleBalloonCheckBoxobject.Therecanbeuptofivecheckboxesinoneballoon;eachcheckboxappearswhenavalueisassignedtoitsTextproperty.
Thefollowingexamplecreatesaballoonwithaheading,text,andthreeregionchoices.TheuserselectsoneormorecheckboxesandclicksOK.Theexamplecallsthespecifiedprocedureorprocedures.
WithAssistant.NewBalloon
.Heading="RegionalSalesData"
.Text="Selectyourregion"
Fori=1To3
.CheckBoxes(i).Text="Region"&i
Next
.Button=msoButtonSetOkCancel
.Show
If.CheckBoxes(1).CheckedThen
runregion1
EndIf
If.CheckBoxes(2).CheckedThen
runregion2
EndIf
If.CheckBoxes(3).CheckedThen
runregion3
EndIf
EndWith
Page 112
Remarks
Ballooncheckboxesdisplaytheuser'schoicesuntiltheuserdismissestheballoon.Youcanuseballoonlabelstoreturnanumbercorrespondingtotheuser'schoiceintheSelectmethodassoonastheuserclicksthebuttonbesidethelabel.TopassvaluestotheSelectmethodbasedontheuser'schoice,youmusthavetheballoontypesettomsoBalloonTypeButtons.
Page 113
BalloonLabelObjectBalloonLabels BalloonLabel
RepresentsalabelintheOfficeAssistantballoon.TheBalloonLabelobjectisamemberoftheBalloonLabelscollection.
Page 114
UsingtheBalloonLabelObject
UseLabels(index),whereindexisanumberfrom1through5,toreturnaBalloonLabelobject.Therecanbeuptofivelabelsononeballoon;eachlabelappearswhenavalueisassisgnedtoitsTextproperty.
Thefollowingexamplecreatesaballoonthataskstheusertoclickthelabelcorrespondingtohisorherage.
WithAssistant.NewBalloon
.Heading="CheckYourAgeGroup."
.Labels(1).Text="Under30."
.Labels(2).Text="30to50."
.Labels(3).Text="Over50."
.Text="Whichofthefollowing"_
&.Labels.Count&"choicesapplytoyou?"
.Show
EndWith
Page 115
Remarks
Ballooncheckboxesdisplaytheuser'schoicesuntilheorshedismissestheballoon.Youcanuseballoonlabelstoreturnanumbercorrespondingtotheuser'schoiceintheSelectmethodassoonastheuserclicksthebuttonbesidethelabel.TopassvaluestotheSelectmethodbasedontheuser'schoice,youmusthavetheballoontypebesettomsoBalloonTypeButtons.
Page 116
COMAddInObjectCOMAddIns COMAddIn
RepresentsaCOMadd-inintheMicrosoftOfficehostapplication.TheCOMAddInobjectisamemberoftheCOMAddInscollection.
UsingtheCOMAddInObject
UseCOMAddIns.Item(index),whereindexiseitheranordinalvaluethatreturnstheCOMadd-inatthatpositionintheCOMAddInscollection,oraStringvaluethatrepresentstheProgIDofthespecifiedCOMadd-in.ThefollowingexampledisplaysaCOMadd-in’sdescriptiontextinamessagebox.
MsgBoxApplication.COMAddIns.Item("msodraa9.ShapeSelect").Description
UsetheProgIDpropertyoftheCOMAddinobjecttoreturntheprogrammaticidentifierforaCOMadd-in,andusetheGuidpropertytoreturnthegloballyuniqueidentifier(GUID)fortheadd-in.ThefollowingexampledisplaystheProgIDandGUIDforCOMadd-inoneinamessagebox.
MsgBox"MyProgIDis"&_
Application.COMAddIns(1).ProgID&_
"andmyGUIDis"&_
Application.COMAddIns(1).Guid
UsetheConnectpropertytosetorreturnthestateoftheconnectiontoaspecifiedCOMadd-in.ThefollowingexampledisplaysamessageboxthatindicateswhetherCOMadd-inoneisregisteredandcurrentlyconnected.
IfApplication.COMAddIns(1).ConnectThen
MsgBox"Theadd-inisconnected."
Else
MsgBox"Theadd-inisnotconnected."
EndIf
Page 119
CommandBarObjectMultipleobjects CommandBar
CommandBarControls
Representsacommandbarinthecontainerapplication.TheCommandBarobjectisamemberoftheCommandBarscollection.
UsingtheCommandBarObject
UseCommandBars(index),whereindexisthenameorindexnumberofacommandbar,toreturnasingleCommandBarobject.Thefollowingexamplestepsthroughthecollectionofcommandbarstofindthecommandbarnamed"Forms."Ifitfindsthiscommandbar,theexamplemakesitvisibleandprotectsitsdockingstate.Inthisexample,thevariablecbrepresentsaCommandBarobject.
foundFlag=False
ForEachcbInCommandBars
Ifcb.Name="Forms"Then
cb.Protection=msoBarNoChangeDock
cb.Visible=True
foundFlag=True
EndIf
Nextcb
IfNotfoundFlagThen
MsgBox"ThecollectiondoesnotcontainaFormscommandbar."
EndIf
Youcanuseanameorindexnumbertospecifyamenubarortoolbarinthelistofavailablemenubarsandtoolbarsinthecontainerapplication.However,youmustuseanametospecifyamenu,shortcutmenu,orsubmenu(allofwhicharerepresentedbyCommandBarobjects).ThisexampleaddsanewmenuitemtothebottomoftheToolsmenu.Whenclicked,thenewmenuitemrunstheprocedurenamed"qtrReport."
SetnewItem=CommandBars("Tools").Controls.Add(Type:=msoControlButton)
WithnewItem
.BeginGroup=True
Page 120
.Caption="MakeReport"
.FaceID=0
.OnAction="qtrReport"
EndWith
Iftwoormorecustommenusorsubmenushavethesamename,CommandBars(index)returnsthefirstone.Toensurethatyoureturnthecorrectmenuorsubmenu,locatethepop-upcontrolthatdisplaysthatmenu.ThenapplytheCommandBarpropertytothepop-upcontroltoreturnthecommandbarthatrepresentsthatmenu.
Assumingthatthethirdcontrolonthetoolbarnamed"CustomTools"isapop-upcontrol,thisexampleaddstheSavecommandtothebottomofthatmenu.
SetviewMenu=CommandBars("CustomTools").Controls(3)
viewMenu.Controls.AddID:=3'IDofSavecommandis3
Page 122
CommandBarButtonObjectCommandBarButton CommandBar
Representsabuttoncontrolonacommandbar.
Page 123
UsingtheCommandBarButtonObject
UseControls(index),whereindexistheindexnumberofthecontrol,toreturnaCommandBarButtonobject.(TheTypepropertyofthecontrolmustbemsoControlButton.)
Assumingthatthesecondcontrolonthecommandbarnamed"Custom"isabutton,thefollowingexamplechangesthestyleofthatbutton.
Setc=CommandBars("Custom").Controls(2)
Withc
If.Type=msoControlButtonThen
If.Style=msoButtonIconThen
.Style=msoButtonIconAndCaption
Else
.Style=msoButtonIcon
EndIf
EndIf
EndWith
YoucanalsousetheFindControlmethodtoreturnaCommandBarButtonobject.
Page 125
CommandBarComboBoxObjectCommandBarComboBox CommandBar
Representsacomboboxcontrolonacommandbar.
Page 126
UsingtheCommandBarComboBoxObject
UseControls(index),whereindexistheindexnumberofthecontrol,toreturnaCommandBarComboBoxobject.(TheTypepropertyofthecontrolmustbemsoControlEdit,msoControlDropdown,msoControlComboBox,msoControlButtonDropdown,msoControlSplitDropdown,msoControlOCXDropdown,msoControlGraphicCombo,ormsoControlGraphicDropdown.)
Thefollowingexampleaddstwoitemstothesecondcontrolonthecommandbarnamed"Custom,"andthenitadjuststhesizeofthecontrol.
Setcombo=CommandBars("Custom").Controls(2)
Withcombo
.AddItem"FirstItem",1
.AddItem"SecondItem",2
.DropDownLines=3
.DropDownWidth=75
.ListIndex=0
EndWith
YoucanalsousetheFindControlmethodtoreturnaCommandBarComboBoxobject.ThefollowingexamplesearchesallcommandbarsforavisibleCommandBarComboBoxobjectwhosetagis"sheetassignments."
SetmyControl=CommandBars.FindControl_
(Type:=msoControlComboBox,Tag:="sheetassignments",Visible:=True)
Page 128
CommandBarControlObjectMultipleobjects CommandBarControl
CommandBar
Representsacommandbarcontrol.TheCommandBarControlobjectisamemberoftheCommandBarControlscollection.ThepropertiesandmethodsoftheCommandBarControlobjectareallsharedbytheCommandBarButton,CommandBarComboBox,andCommandBarPopupobjects.
NoteWhenwritingVisualBasiccodetoworkwithcustomcommandbarcontrols,youusetheCommandBarButton,CommandBarComboBox,andCommandBarPopupobjects.Whenwritingcodetoworkwithbuilt-incontrolsinthecontainerapplicationthatcannotberepresentedbyoneofthosethreeobjects,youusetheCommandBarControlobject.
Page 129
UsingtheCommandBarControlObject
UseControls(index),whereindexistheindexnumberofacontrol,toreturnaCommandBarControlobject.(TheTypepropertyofthecontrolmustbemsoControlLabel,msoControlExpandingGrid,msoControlSplitExpandingGrid,msoControlGrid,ormsoControlGauge.)
NoteVariablesdeclaredasCommandBarControlcanbeassignedCommandBarButton,CommandBarComboBox,andCommandBarPopupvalues.
YoucanalsousetheFindControlmethodtoreturnaCommandBarControlobject.ThefollowingexamplesearchesforacontroloftypemsoControlGauge;ifitfindsone,itdisplaystheindexnumberofthecontrolandthenameofthecommandbarthatcontainsit.Inthisexample,thevariablelblrepresentsaCommandBarControlobject.
Setlbl=CommandBars.FindControl(Type:=msoControlGauge)
IflblIsNothingThen
MsgBox"AcontroloftypemsoControlGaugewasnotfound."
Else
MsgBox"Control"&lbl.Index&"oncommandbar"_
&lbl.Parent.Name&"istypemsoControlGauge"
EndIf
Page 131
CommandBarPopupObjectCommandBarPopup Multipleobjects
Representsapop-upcontrolonacommandbar.
Page 132
UsingtheCommandBarPopupObject
UseControls(index),whereindexisthenumberofthecontrol,toreturnaCommandBarPopupobject.(TheTypepropertyofthecontrolmustbemsoControlPopup,msoControlGraphicPopup,msoControlButtonPopup,msoControlSplitButtonPopup,ormsoControlSplitButtonMRUPopup.)
YoucanalsousetheFindControlmethodtoreturnaCommandBarPopupobject.ThefollowingexamplesearchesallcommandbarsforaCommandBarPopupobjectwhosetagis"Graphics."
SetmyControl=Application.CommandBars.FindControl_
(Type:=msoControlPopup,Tag:="Graphics")
Page 133
Remarks
Everypop-upcontrolcontainsaCommandBarobject.Toreturnthecommandbarfromapop-upcontrol,applytheCommandBarpropertytotheCommandBarPopupobject.
Page 134
DocumentLibraryVersionObjectDocumentLibraryVersions DocumentLibraryVersion
TheDocumentLibraryVersionobjectrepresentsasinglesavedversionofashareddocumentwhichhasversioningenabledandwhichisstoredinadocumentlibraryontheserver.EachDocumentLibraryVersionobjectisamemberoftheactivedocument'sDocumentLibraryVersionscollection.
Page 135
UsingtheDocumentLibraryVersionObject
EachDocumentLibraryVersionobjectrepresentsonesavedversionoftheactivedocument.Whenversioningisenabled,anewversioniscreatedontheserverwhentheactionslistedbelowoccur;additionalversionsarenotcreatedeachtimetheusersaveschangestotheopendocument.
CheckInSave-Anewversioniscreatedontheserverwhentheuserfirstsavesthedocumentafteropeningit.Additionalchangessavedwhilethedocumentisopenapplytothesameversion.RestoreUpload
UsetheModified,ModifiedBy,andCommentspropertiestoreturninformationaboutasavedversionofashareddocument.
UsetheOpenmethodtoopenapreviousversion,ortheRestoremethodtorestoreapreviousversioninplaceofthecurrentversion.UsetheDeletemethodtodeleteaversion.
Page 136
Example
Thefollowingexampledisplaysthepropertiesofeachsavedversionoftheactivedocument.
DimdlvVersionsAsOffice.DocumentLibraryVersions
DimdlvVersionAsOffice.DocumentLibraryVersion
DimstrVersionInfoAsString
SetdlvVersions=ActiveDocument.DocumentLibraryVersions
IfdlvVersions.IsVersioningEnabledThen
strVersionInfo="Thisdocumenthas"&_
dlvVersions.Count&"versions:"&vbCrLf
ForEachdlvVersionIndlvVersions
strVersionInfo=strVersionInfo&_
"-Version#:"&dlvVersion.Index&vbCrLf&_
"-Modifiedby:"&dlvVersion.ModifiedBy&vbCrLf&_
"-Modifiedon:"&dlvVersion.Modified&vbCrLf&_
"-Comments:"&dlvVersion.Comments&vbCrLf
Next
Else
strVersionInfo="Versioningnotenabledforthisdocument."
EndIf
MsgBoxstrVersionInfo,vbInformation+vbOKOnly,"VersionInformation"
SetdlvVersion=Nothing
SetdlvVersions=Nothing
Page 137
DocumentPropertyObjectRepresentsacustomorbuilt-indocumentpropertyofacontainerdocument.TheDocumentPropertyobjectisamemberoftheDocumentPropertiescollection.
Page 138
UsingtheDocumentPropertyObject
UseBuiltinDocumentProperties(index),whereindexisthenameorindexnumberofthebuilt-indocumentproperty,toreturnasingleDocumentPropertyobjectthatrepresentsaspecificbuilt-indocumentproperty.UseCustomDocumentProperties(index),whereindexisthenameorindexnumberofthecustomdocumentproperty,toreturnaDocumentPropertyobjectthatrepresentsaspecificcustomdocumentproperty.
Thefollowinglistcontainsthenamesofalltheavailablebuilt-indocumentproperties:
Title
Subject
Author
Keywords
Comments
Template
LastAuthor
RevisionNumber
ApplicationName
LastPrintDate
CreationDate
LastSaveTime
TotalEditingTime
NumberofPages
NumberofWords
NumberofCharacters
Security
Category
Format
Manager
Company
NumberofBytes
NumberofLines
NumberofParagraphs
NumberofSlides
NumberofNotes
NumberofHiddenSlides
NumberofMultimediaClips
Page 139
Containerapplicationsdon'tnecessarilydefineavalueforeverybuilt-indocumentproperty.Ifagivenapplicationdoesn'tdefineavalueforoneofthebuilt-indocumentproperties,returningtheValuepropertyforthatdocumentpropertycausesanerror.
Page 140
FileDialogObjectFileDialog Multipleobjects
ProvidesfiledialogboxfunctionalitysimilartothefunctionalityofthestandardOpenandSavedialogboxesfoundinMicrosoftOfficeapplications.Withthesedialogboxes,usersofyoursolutionscaneasilyspecifythefilesandfoldersthatyoursolutionshoulduse.
Page 141
UsingtheFileDialogobject
UsetheFileDialogpropertytoreturnaFileDialogobject.TheFileDialogpropertyislocatedineachindividualOfficeapplication'sApplicationobject.Thepropertytakesasingleargument,DialogType,thatdeterminesthetypeofFileDialogobjectthatthepropertyreturns.TherearefourtypesofFileDialogobject:
Opendialogbox-letsusersselectoneormorefilesthatyoucanthenopeninthehostapplicationusingtheExecutemethod.SaveAsdialogbox-letsusersselectasinglefilethatyoucanthensavethecurrentfileasusingtheExecutemethod.FilePickerdialogbox-letsusersselectoneormorefiles.ThefilepathsthattheuserselectsarecapturedintheFileDialogSelectedItemscollection.FolderPickerdialogbox-letsusersselectapath.ThepaththattheuserselectsiscapturedintheFileDialogSelectedItemscollection.
EachhostapplicationcanonlyinstantiateasingleinstanceoftheFileDialogobject.Therefore,manyofthepropertiesoftheFileDialogobjectpersistevenwhenyoucreatemultipleFileDialogobjects.Therefore,makesurethatyou'vesetallofthepropertiesappropriatelyforyourpurposebeforeyoudisplaythedialogbox.
InordertodisplayafiledialogboxusingtheFileDialogobject,youmustusetheShowmethod.Onceadialogboxisdisplayed,nocodewillexecuteuntiltheuserdismissesthedialogbox.ThefollowingexamplecreatesanddisplaysaFilePickerdialogboxandthendisplayseachselectedfileinamessagebox.
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
Page 142
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Theuserpressedtheactionbutton.
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Thepathis:"&vrtSelectedItem
NextvrtSelectedItem
'TheuserpressedCancel.
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Setfd=Nothing
EndSub
Page 143
FileDialogFilterObjectFileDialogFilters FileDialogFilter
RepresentsafilefilterinafiledialogboxdisplayedthroughtheFileDialogobject.Eachfilefilterdetermineswhichfilesaredisplayedinthefiledialogbox.
Page 144
UsingtheFileDialogFilterobject
UsetheItemmethodwiththeFileDialogFilterscollectiontoreturnaFileDialogFilterobject.UsetheAddmethodtoaddaFileDialogFilterobjecttotheFileDialogFilterscollection.YoucanreturntheextensionsthataFileDialogFilterobjectusestofilterfileswiththeExtensionspropertyandyoucanreturnthedescriptionofthefilterwiththeDescriptionproperty;however,bothofthesepropertiesareread-only.IfyouwanttosettheextensionordescriptionyoumustusetheAddmethod.
ThefollowingexampleiteratesthroughthedefaultfiltersoftheSaveAsdialogboxanddisplaysthedescriptionofeachfilterthatincludesaMicrosoftExcelfile.
SubMain()
'DeclareavariableasaFileDialogFilterscollection.
DimfdfsAsFileDialogFilters
'DeclareavariableasaFileDialogFilterobject.
DimfdfAsFileDialogFilter
'SettheFileDialogFilterscollectionvariableto
'theFileDialogFilterscollectionoftheSaveAsdialogbox.
Setfdfs=Application.FileDialog(msoFileDialogSaveAs).Filters
'Iteratethroughthedescriptionandextensionsofeach
'defaultfilterintheSaveAsdialogbox.
ForEachfdfInfdfs
'Displaythedescriptionoffiltersthatinclude
'MicrosoftExcelfiles.
IfInStr(1,fdf.Extensions,"xls",vbTextCompare)>0Then
MsgBox"Descriptionoffilter:"&fdf.Description
EndIf
Nextfdf
EndSub
Page 146
FileSearchObjectFileSearch Multipleobjects
RepresentsthefunctionalityoftheOpendialogbox(Filemenu).
Page 147
UsingtheFileSearchObject
UsetheFileSearchpropertytoreturntheFileSearchobject.Thefollowingexamplesearchesforfilesanddisplaysthenumberoffilesfoundandthenameofeachfile.
WithApplication.FileSearch
If.Execute()>0Then
MsgBox"Therewere"&.FoundFiles.Count&_
"file(s)found."
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
Nexti
Else
MsgBox"Therewerenofilesfound."
EndIf
EndWith
UsetheNewSearchmethodtoresetthesearchcriteriatothedefaultsettings.Allpropertyvaluesareretainedaftereachsearchisrun,andbyusingtheNewSearchmethodyoucanselectivelysetpropertiesforthenextfilesearchwithoutmanuallyresettingpreviouspropertyvalues.Thefollowingexampleresetsthesearchcriteriatothedefaultsettingsbeforebeginninganewsearch.
WithApplication.FileSearch
.NewSearch
.LookIn="C:\MyDocuments"
.SearchSubFolders=True
.FileName="Run"
.MatchTextExactly=True
.FileType=msoFileTypeAllFiles
EndWith
Page 148
HTMLProjectObjectHTMLProject HTMLProjectItems
Representsatop-levelprojectbranch,asintheProjectExplorerintheMicrosoftScriptEditor.
UsingtheHTMLProjectObject
UsetheOpenmethodoftheHTMLProjectobjecttoopenanHTMLprojectintheMicrosoftScriptEditor.TheprojectisopenedinsourceviewortextviewfortheactiveMicrosoftWorddocument,Excelworkbook,orPowerPointpresentation.ThefollowingexampleopensanHTMLprojectintheactiveWorddocumentinsourceview.
ActiveDocument.HTMLProject.Open(msoHTMLProjectOpenSourceView)
UsetheHTMLProjectItemspropertytoreturnthecollectionofHTMLProjectItemobjectsintheHTMLproject.UsetheRefreshDocumentmethodtorefreshtheHTMLdocumentinthehostapplication.UsetheRefreshProjectmethodtorefreshtheprojectintheMicrosoftScriptEditor.UsetheStatemethodtodeterminewhethertheHTMLprojectneedstoberefreshed.
Page 149
HTMLProjectItemObjectHTMLProjectItems HTMLProjectItem
Representsanindividualprojectitemthat’saprojectitembranchintheProjectExplorerintheMicrosoftScriptEditor.TheHTMLProjectItemobjectisamemberoftheHTMLProjectItemscollection.
UsingtheHTMLProjectItemObject
UseHTMLProjectItems(index),whereindexisthenameorindexnumberofaprojectitem,toreturnasingleHTMLProjectItemobject.UsetheNamepropertytoreturnthedisplaynameoftheprojectitem.ThefollowingexamplereturnsthenameofthefirstprojectitemintheHTMLProjectItemscollectionfortheactivedocument.
MsgBox"Thefirstitemis"&_
ActiveDocument.HTMLProject.HTMLProjectItems(1).Name
UsetheOpenmethodtoopenaprojectiteminsourceviewortextview,andusetheIsOpenpropertytodeterminewhethertheprojectitemiscurrentlyopen.Thefollowingexampleopenstheprojectitemnamed“ItemOne”(intheactivedocument)inthedefaultviewandthendisplaysamessageboxstatingwhethertheitemwasopenedsuccessfully.
ActiveDocument.HTMLProject.HTMLProjectItems("ItemOne").Open
IfActiveDocument.HTMLProject._
HTMLProjectItems("ItemOne").IsOpenThen
MsgBox"Openedprojectitem"&ActiveDocument.HTMLProject.HTMLProjectItems("ItemOne").Name
EndIf
UsetheSaveCopyAsmethodtosavetheprojectitemusinganewfilename.ThefollowingexamplesavesacopyofItemOneas“NewItem”.
ActiveDocument.HTMLProject.HTMLProjectItems("ItemOne")_
.Open(msoHTMLProjectOpenTextView)
ActiveDocument.HTMLProject.HTMLProjectItems("ItemOne")_
.SaveCopyAs("C:\NewItem.txt")
Page 150
AssumingthatthetextfileC:\NewText.txtexists,thefollowingexampleusestheLoadFromFilepropertytosetthetextofItemOnetothetextcontainedinthefile.ThefollowingexampleusestheTextpropertytodisplaythenewtextinamessagebox.
MsgBoxActiveDocument.HTMLProject.HTMLProjectItems_
("ItemOne").Text
ActiveDocument.HTMLProject.HTMLProjectItems_
("ItemOne").LoadFromFile("C:\NewText.txt")
MsgBoxActiveDocument.HTMLProject.HTMLProjectItems_
("ItemOne").Text
Page 152
LanguageSettingsObjectLanguageSettings
ReturnsinformationaboutthelanguagesettingsinaMicrosoftOfficeapplication.
UsingtheLanguageSettingsObject
UseApplication.LanguageSettings.LanguageID(MsoAppLanguageID),whereMsoAppLanguageIDisaconstantusedtoreturnlocaleidentifier(LCID)informationtothespecifiedapplication.
MsoAppLanguageIDcanbeoneoftheseMsoAppLanguageIDconstants.msoLanguageIDExeModemsoLanguageIDHelpmsoLanguageIDInstallmsoLanguageIDUImsoLanguageIDUIPrevious
Thefollowingexamplereturnstheinstalllanguage,userinterfacelanguage,andHelplanguageLCIDsinamessagebox.
MsgBox"ThefollowinglocaleIDsareregistered"&_
"forthisapplication:InstallLanguage-"&_
Application.LanguageSettings.LanguageID(msoLanguageIDInstall)&_
"UserInterfaceLanguage-"&_
Application.LanguageSettings.LanguageID(msoLanguageIDUI)&_
"HelpLanguage-"&_
Application.LanguageSettings.LanguageID(msoLanguageIDHelp)
UseApplication.LanguageSettings.LanguagePreferredForEditingtodeterminewhichLCIDsareregisteredaspreferrededitinglanguagesfortheapplication,asinthefollowingexample.
IfApplication.LanguageSettings._
LanguagePreferredForEditing(msoLanguageIDEnglishUS)Then
MsgBox"U.S.Englishisoneofthechoseneditinglanguagess."
Page 154
MsoEnvelopeObjectMsoEnvelope
ProvidesaccesstofunctionalitythatletsyousenddocumentsasemailsdirectlyfromMicrosoftOfficeapplications.
Page 155
UsingtheMsoEnvelopeobject
UsetheMailEnvelopepropertyoftheDocumentobject,ChartobjectorWorksheetobject(dependingontheapplicationyouareusing)toreturnaMsoEnvelopeobject.
ThefollowingexamplesendstheactiveMicrosoftWorddocumentasane-mailtothee-mailaddressthatyoupasstothesubroutine.
SubSendMail(ByValstrRecipientAsString)
'UseaWith...EndWithblocktoreferencetheMsoEnvelopeobject.
WithApplication.ActiveDocument.MailEnvelope
'Addsomeintroductorytextbeforethebodyofthee-mail.
.Introduction="Pleasereadthisandsendmeyourcomments."
'ReturnaMicrosoftOutlookMailItemobjectthat
'youcanusetosendthedocument.
With.Item
'Allofthemailitemsettingsaresavedwiththedocument.
'WhenyouaddarecipienttotheRecipientscollection
'orchangeotherproperties,thesesettingswillpersist.
.Recipients.AddstrRecipient
.Subject="Hereisthedocument."
'Thebodyofthismessagewillbe
'thecontentoftheactivedocument.
.Send
EndWith
EndWith
EndSub
Page 156
NewFileObjectNewFile
TheNewFileobjectrepresentsitemslistedontheNewItemtaskpaneavailableinseveralMicrosoftOfficeapplications.ThefollowingtableshowsthepropertytousetoaccesstheNewFileobjectineachoftheapplications.
Application PropertyMicrosoftAccess NewFileTaskPaneMicrosoftExcel NewWorkbookMicrosoftFrontPage NewPageOrWebMicrosoftPowerPoint NewPresentationMicrosoftWord NewDocument
NoteTheexamplesbelowareforWord,butyoucanchangetheNewDocumentpropertyforanyofthepropertieslistedaboveandusethecodeinthecorrespondingapplication.
Page 157
UsingtheNewFileobject
UsetheAddmethodtoaddanewitemtotheNewItemtaskpane.ThefollowingexampleaddsanitemtoWord'sNewDocumenttaskpane.
SubAddNewDocToTaskPane()
Application.NewDocument.AddFileName:="C:\NewDocument.doc",_
Section:=msoNew,DisplayName:="NewDocument"
CommandBars("TaskPane").Visible=True
EndSub
UsetheRemovemethodtoremoveanitemfromtheNewItemtaskpane.ThefollowingexampleremovesthedocumentaddedintheaboveexamplefromWord'sNewDocumenttaskpane.
SubRemoveDocFromTaskPane()
Application.NewDocument.RemoveFileName:="C:\NewDocument.doc",_
Section:=msoNew,DisplayName:="NewDocument"
CommandBars("TaskPane").Visible=True
EndSub
Page 158
ODSOColumnObjectODSOColumns ODSOColumn
Representsafieldinadatasource.TheODSOColumnobjectisamemberoftheODSOColumnscollection.TheODSOColumnscollectionincludesallthedatafieldsinamailmergedatasource(forexample,Name,Address,andCity).
Page 159
UsingtheODSOColumnobject
UseColumns(index),whereindexisthedatafieldnameorindexnumber,toreturnasingleODSOColumnobject.Theindexnumberrepresentsthepositionofthedatafieldinthemailmergedatasource.Thisexampleretrievesthenameandvalueofthefirstfieldofthefirstrecordinthedatasourceattachedtotheactivepublication.
SubGetDataFromSource()
DimappOfficeAsOfficeDataSourceObject
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Columns
MsgBox"FieldName:"&.Item(1).Name&vbLf&_
"Value:"&.Item(1).Value
EndWith
EndSub
Page 160
Remarks
YoucannotaddfieldstotheODSOColumnscollection.AlldatafieldsinadatasourceareautomaticallyincludedintheODSOColumnscollection.
Page 161
ODSOFilterObjectODSOFilters ODSOFilter
Representsafiltertobeappliedtoanattachedmailmergedatasource.TheODSOFilterobjectisamemberoftheODSOFiltersobject.
Page 162
UsingtheODSOFilterobject
Eachfilterisalineinaquerystring.UsetheColumn,Comparison,CompareTo,andConjunctionpropertiestoreturnorsetthedatasourcequerycriterion.ThefollowingexamplechangesanexistingfiltertoremovefromthemailmergeallrecordsthatdonothaveaRegionfieldequalto"WA".
SubSetQueryCriterion()
DimappOfficeAsOffice.OfficeDataSourceObject
DimintItemAsInteger
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Filters
ForintItem=1To.Count
With.Item(intItem)
If.Column="Region"Then
.Comparison=msoFilterComparisonNotEqual
.CompareTo="WA"
If.Conjunction="Or"Then.Conjunction="And"
EndIf
EndWith
NextintItem
EndWith
EndSub
UsetheAddmethodoftheODSOFiltersobjecttoaddanewfiltercriteriontothequery.Thisexampleaddsanewlinetothequerystringandthenappliesthecombinedfiltertothedatasource.
SubSetQueryCriterion()
DimappOfficeAsOfficeDataSourceObject
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Filters
.AddColumn:="Region",_
Comparison:=msoFilterComparisonIsBlank,_
Conjunction:=msoFilterConjunctionAnd
.ApplyFilter
Page 164
OfficeDataSourceObjectObjectOfficeDataSourceObject
Representsthemailmergedatasourceinamailmergeoperation.
Page 165
UsingtheOfficeDataSourceObjectobject
ToworkwiththeOfficeDataSourceObjectobject,dimensionavariableasanOfficeDataSourceObjectobject.Youcanthenworkwiththedifferentpropertiesandmethodsassociatedwiththeobject.UsetheSetSortOrdermethodtospecifyhowtosorttherecordsinadatasource.ThefollowingexamplesortsthedatasourcefirstaccordingtoZIPcodeindescendingorder,thenonlastnameandfirstnameinascendingorder.
SubSetDataSortOrder()
DimappOfficeAsOfficeDataSourceObject
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
appOffice.SetSortOrderSortField1:="ZipCode",_
SortAscending1:=False,SortField2:="LastName",_
SortField3:="FirstName"
EndSub
UsetheColumn,Comparison,CompareTo,andConjunctionpropertiestoreturnorsetthedatasourcequerycriterion.ThefollowingexamplechangesanexistingfiltertoremovefromthemailmergeallrecordsthatdonothaveaRegionfieldequalto"WA".
SubSetQueryCriterion()
DimappOfficeAsOffice.OfficeDataSourceObject
DimintItemAsInteger
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Filters
ForintItem=1To.Count
With.Item(intItem)
If.Column="Region"Then
.Comparison=msoFilterComparisonNotEqual
.CompareTo="WA"
If.Conjunction="Or"Then.Conjunction="And"
EndIf
EndWith
NextintItem
Page 167
PermissionObjectPermission UserPermission
ThePermissionpropertyoftheMicrosoftOfficeWord2003Documentobject,theMicrosoftOfficeExcel2003Workbookobject,andtheMicrosoftOfficePowerPoint2003PresentationobjectreturnsaPermissionobject.
Page 168
UsingthePermissionObject
UsethePermissionobjecttorestrictpermissionstotheactivedocumentandtoreturnorsetspecificpermissionssettings.
UsetheEnabledpropertytodeterminewhetherpermissionsarerestrictedontheactivedocument.UsetheCountpropertytoreturnthenumberofuserswithpermissions,andtheRemoveAllmethodtoresetallexistingpermissions.
TheDocumentAuthor,EnableTrustedBrowser,RequestPermissionURL,andStoreLicensespropertiesprovideadditionalinformationaboutpermissionssettings.
ThePermissionobjectgivesaccesstoacollectionofUserPermissionobjects.UsetheUserPermissionobjecttoassociatespecificsetsofrightswithindividualusers.Whilesomepermissionsgrantedthroughtheuserinterface(suchasmsoPermissionPrint)applytoallusers,youcanusetheUserPermissionobjecttoassignthemonaper-userbasiswithper-userexpirationdates.
MicrosoftOfficeInformationRightsManagementsupportstheuseofadministrativepermissionpolicieswhichlistusersandgroupsandtheirdocumentpermissions.UsetheApplyPolicymethodtoapplyapermissionpolicy,andthePermissionFromPolicy,PolicyName,andPolicyDescriptionpropertiestoreturnpolicyinformation.
ThePermissionobjectmodelisavailablewhetherpermissionsarerestrictedontheactivedocumentornot.ThePermissionpropertyoftheDocument,WorkbookandPresentationobjectsdoesnotreturnNothingwhentheactivedocumentdoesnothaverestrictedpermissions.UsetheEnabledpropertytodeterminewhetheradocumenthasrestrictedpermissions.
UseofthePermissionobjectraisesanerrorwhentheWindowsRightsManagementclientisnotinstalled.
Page 169
Example
Thefollowingexamplereturnsinformationaboutthepermissionssettingsontheactivedocument.
DimirmPermissionAsOffice.Permission
DimstrIRMInfoAsString
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
strIRMInfo="Permissionsarerestrictedonthisdocument."&vbCrLf
strIRMInfo=strIRMInfo&"Viewintrustedbrowser:"&_
irmPermission.EnableTrustedBrowser&vbCrLf&_
"Documentauthor:"&irmPermission.DocumentAuthor&vbCrLf&_
"Userswithpermissions:"&irmPermission.Count&vbCrLf&_
"Cachelicenses:"&irmPermission.StoreLicenses&vbCrLf&_
"RequestpermissionURL:"&irmPermission.RequestPermissionURL&vbCrLf
IfirmPermission.PermissionFromPolicyThen
strIRMInfo=strIRMInfo&"Permissionsappliedfrompolicy:"&vbCrLf&_
"Policyname:"&irmPermission.PolicyName&vbCrLf&_
"Policydescription:"&irmPermission.PolicyDescription
Else
strIRMInfo=strIRMInfo&"Defaultpermissionsapplied."&vbCrLf&_
"Defaultpolicyname:"&irmPermission.PolicyName&vbCrLf&_
"Defaultpolicydescription:"&irmPermission.PolicyDescription
EndIf
Else
strIRMInfo="PermissionsareNOTrestrictedonthisdocument."
EndIf
MsgBoxstrIRMInfo,vbInformation+vbOKOnly,"IRMInformation"
SetirmPermission=Nothing
Page 170
PropertyTestObjectFileSearch PropertyTests
PropertyTest
Representsasinglefilesearchcriterion.SearchcriteriaarelistedintheAdvancedFinddialogbox(Filemenu,Opencommand,AdvancedFindbutton).ThePropertyTestobjectisamemberofthePropertyTestscollection.
Page 171
UsingthePropertyTestObject
UsePropertyTests(index),whereindexistheindexnumber,toreturnasinglePropertyTestobject.ThefollowingexampledisplaysallthesearchcriteriaforthefirstpropertytestinthePropertyTestscollection.
WithApplication.FileSearch.PropertyTests(1)
myString="Thisisthesearchcriteria:"_
&"Thenameis:"&.Name&".Theconditionis:"_
&.Condition
If.Value<>""Then
myString=myString&".Thevalueis:"&.Value
If.SecondValue<>""Then
myString=myString_
&".Thesecondvalueis:"_
&.SecondValue&",andtheconnectoris"_
&.Connector
EndIf
EndIf
MsgBoxmyString
EndWith
Page 172
ScopeFolderObjectMultipleobjects ScopeFolder
ScopeFolders
Correspondstoasearchablefolder.ScopeFolderobjectsareintendedforusewiththeSearchFolderscollection.TheSearchFolderscollectiondefinesthefoldersthataresearchedwhenusingtheFileSearchobject.WhenyouwanttosearchspecificfoldersyoucanusethemethodsandpropertiesoftheSearchScopeobjectandScopeFolderscollectiontoretrieveScopeFolderobjectsandaddthemtotheSearchFolderscollection.
Page 173
UsingtheScopeFolderobject
UsetheScopeFolderpropertyoftheSearchScopeobjecttoreturntherootScopeFolderobjectofasearchscope;forexample:
Setsf=Application.FileSearch.SearchScopes.Item(1).ScopeFolder
UsetheItemmethodoftheScopeFolderscollectiontoreturnasubfolderofarootScopeFolderobject;forexample:
Setsf=Application.FileSearch.SearchScopes.Item(1).ScopeFolder.ScopeFolders.Item(1)
UsetheItemmethodoftheSearchFolderscollectiontoreturnafolderthatwillbesearchedthenexttimetheExecutemethodoftheFileSearchobjectiscalled;forexample:
Setsf=Application.FileSearch.SearchFolders.Item(1)
IneachScopeFolderobjectthereisaScopeFolderscollectionthatcontainsthesubfoldersoftheparentScopeFolderobject.Youcantraversetheentirefolderstructureofasearchscope(forexample,alllocaldrives)byloopingthroughtheseScopeFolderscollectionsandreturningallofthelower-levelScopeFolderobjects.AScopeFolderobjectwithnosubfolderscontainsanemptyScopeFolderscollection.
ForanexamplethatdemonstrateshowtoloopthroughalloftheScopeFolderobjectsinasearchscope,seetheSearchFolderscollectiontopic.
YoucanusetheAddmethodoftheSearchFolderscollectiontoaddaScopeFolderobjecttotheSearchFolderscollection,however,itisusuallysimplertousetheAddToSearchFoldersmethodoftheScopeFolderthatyouwanttoadd,asthereisonlyoneSearchFolderscollectionforallsearches.
ForanexamplethatdemonstrateshowtoaddaScopeFoldertotheSearchFolderscollection,seetheSearchFolderscollectiontopic.
ThefollowingexampledisplaystherootpathofeachdirectoryinMyComputer.
Page 174
Toretrievethisinformation,theexamplefirstgetstheScopeFolderobjectattherootofMyComputer.ThepathofthisScopeFolderobjectwillalwaysbe"*".AswithallScopeFolderobjects,therootobjectcontainsaScopeFolderscollection.ThisexampleloopsthroughthisScopeFolderscollectionanddisplaysthepathofeachScopeFolderobjectinit.ThepathsoftheseScopeFolderobjectswillbe"A:\","C:\",etc.
SubDisplayRootScopeFolders()
'Declarevariablesthatreferencea
'SearchScopeandaScopeFolderobject.
DimssAsSearchScope
DimsfAsScopeFolder
'UseaWith...EndWithblocktoreferencethe
'FileSearchobject.
WithApplication.FileSearch
'LoopthroughtheSearchScopescollection
'anddisplayalloftherootScopeFolderscollectionsin
'theMyComputerscope.
ForEachssIn.SearchScopes
SelectCasess.Type
CasemsoSearchInMyComputer
'LoopthrougheachScopeFolderobjectin
'theScopeFolderscollectionofthe
'SearchScopeobjectanddisplaythepath.
ForEachsfInss.ScopeFolder.ScopeFolders
MsgBox"ScopeFolderobject'spath:"&sf.Path
Nextsf
CaseElse
EndSelect
Next
EndWith
EndSub
Page 175
ScriptObjectScripts Script
RepresentsablockofHTMLscriptinaMicrosoftWorddocument,onaMicrosoftExcelspreadsheet,oronaMicrosoftPowerPointslide.TheScriptobjectisamemberoftheScriptscollection.
UsingtheScriptObject
UseScripts.Item(index),whereindexisthename,ID,orindexnumberofascript,toreturnasingleScriptobject.EachScriptobjectisidentifiedbytheIdproperty,whichprovidesaconvenientnameyoucanusetoaccessthescript.ThefollowingexampleaddsasinglescripttotheScriptscollectionfortheactivedocumentanddisplaystheIDofthescriptatindexvalue1.
myScript=ActiveDocument.Scripts.Add(_
,msoScriptLocationInBody,_
msoScriptLanguageVisualBasic,_
"ScriptOne",,_
"MsgBox(""ThisisScriptOne."")")
MsgBox(ActiveDocument.Scripts(1).Id)
YoucanspecifythescriptinglanguageusedinthescriptbychangingtheLanguageproperty.ThefollowingexamplechangesthescriptinglanguageofscriptonetoActiveServerPages(ASP).
ActiveDocument.Scripts.Item("ScriptOne")_
.Language=msoScriptLanguageASP
YoucancheckthelocationofthescriptanchorshapewithinanHTMLdocumentbyusingtheLocationproperty.ThefollowingexamplecheckstodeterminewhetherScriptOneisinthebodyoftheactiveHTMLdocument.
IfActiveDocument.Scripts("ScriptOne").Location=_
msoScriptLocationInBodyThen
MsgBox("ScriptisintheHTMLdocumentbody.")
Else
Page 176
MsgBox("Scriptislocatedintheheader.")
EndIf
Youcancheckorsetattributesaddedtothe<SCRIPT>tag(withtheexceptionoftheLANGUAGEandIDattributes)byusingtheExtendedproperty.Thefollowingexamplechecksforadditionalattributesinscriptoneintheactivedocument.
IfActiveDocument.Scripts(1).Extended=""Then
MsgBox("Noadditionalattributesarepresent"&_
"inScript"&
ActiveDocument.Scripts(1).Id)
YoucancheckorsetthescripttextassociatedwithagivenscriptbyusingtheScriptTextproperty.Thefollowingexampledisplaysamessageboxcontainingthescripttextassociatedwithscriptoneintheactivedocument.
MsgBox(ActiveDocument.Scripts("ScriptOne").ScriptText)
Page 177
SearchScopeObjectFileSearch SearchScopes
SearchScopeScopeFolder
CorrespondstoatypeoffoldertreethatcanbesearchedbyusingtheFileSearchobject.Forexample,thelocaldrivesonthiscomputerrepresentasinglesearchscope.NetworkfoldersandMicrosoftOutlookfoldersarealsoseparatesearchscopesthatmaybeavailable.EachSearchScopeobjectcontainsasingleScopeFolderobjectthatcorrespondstotherootfolderofthesearchscope.
Page 178
UsingtheSearchScopeobject
UsetheItemmethodoftheSearchScopescollectiontoreturnaSearchScopeobject;forexample:
DimssAsSearchScope
Setss=Application.FileSearch.SearchScopes.Item(1)
Ultimately,theSearchScopeobjectisintendedtoprovideaccesstoScopeFolderobjectsthatcanbeaddedtotheSearchFolderscollection.Foranexamplethatdemonstrateshowthisisaccomplished,seetheSearchFolderscollectiontopic.
SeetheScopeFolderobjecttopictoseeasimpleexampleofhowtoreturnaScopeFolderobjectfromaSearchScopeobject.
ThefollowingexampledisplaysallofthecurrentlyavailableSearchScopeobjects.
SubDisplayAvailableScopes()
'Declareavariablethatreferencesa
'SearchScopeobject.
DimssAsSearchScope
'UseaWith...EndWithblocktoreferencethe
'FileSearchobject.
WithApplication.FileSearch
'LoopthroughtheSearchScopescollection.
ForEachssIn.SearchScopes
SelectCasess.Type
CasemsoSearchInMyComputer
MsgBox"MyComputerisanavailablesearchscope."
CasemsoSearchInMyNetworkPlaces
MsgBox"MyNetworkPlacesisanavailablesearchscope."
CasemsoSearchInOutlook
MsgBox"Outlookisanavailablesearchscope."
CasemsoSearchInCustom
MsgBox"Acustomsearchscopeisavailable."
CaseElse
MsgBox"Can'tdeterminesearchscope."
EndSelect
Page 179
Nextss
EndWith
EndSub
Page 180
SharedWorkspaceObjectSharedWorkspace Multipleobjects
TheSharedWorkspacepropertyofaMicrosoftOfficeWord2003Documentobject,MicrosoftOfficeExcel2003Workbookobject,andMicrosoftOfficePowerPoint2003PresentationobjectreturnsaSharedWorkspaceobjectwhichallowsthedevelopertoaddtheactivedocumenttoaMicrosoftWindowsSharePointServicesdocumentworkspaceontheserverandtomanageotherobjectsinthesharedworkspace.
Page 181
UsingtheSharedWorkspaceObject
UsetheSharedWorkspaceobjecttoaddtheactiveWord,ExcelorPowerPointdocumenttoaWindowsSharePointServicesdocumentworkspaceontheserverinordertotakeadvantageoftheworkspace'scollaborationfeatures,ortodisconnectorremovethedocumentfromtheworkspace.UsetheSharedWorkspaceobject'scollectionstomanagefiles,folders,links,membersandtasksassociatedwiththeshareddocument.
TheSharedWorkspaceobjectmodelisavailablewhetherornotadocumentisstoredinaworkspace.TheSharedWorkspacepropertyoftheDocument,WorkbookandPresentationobjectsdoesnotreturnNothingwhenthedocumentisnotshared.UsetheConnectedpropertyoftheSharedWorkspaceobjecttodeterminewhethertheactivedocumentisinfactsavedinandconnectedtoasharedworkspace.
Usersrequireappropriatepermissionstousetheobjects,propertiesandmethodsintheSharedWorkspaceobjecthierarchy.
UsetheSharedWorkspaceFilescollection,accessedthroughtheFilespropertyoftheSharedWorkspaceobject,tomanagedocumentsandfilessavedinasharedworkspace.
UsetheSharedWorkspaceFolderscollection,accessedthroughtheFolderspropertyoftheSharedWorkspaceobject,tomanagesubfolderswithinthemaindocumentlibraryfolderofasharedworkspace.
UsetheSharedWorkspaceLinkscollection,accessedthroughtheLinkspropertyoftheSharedWorkspaceobject,tomanagelinkstoadditionaldocumentsandinformationofinteresttothememberswhoarecollaboratingonthedocument(s)inthesharedworkspace.
UsetheSharedWorkspaceMemberscollection,accessedthroughtheMemberspropertyoftheSharedWorkspaceobject,tomanageuserswhohaverightstoparticipateinasharedworkspaceandtocollaborateontheshareddocument(s)savedintheworkspace.
UsetheSharedWorkspaceTaskscollection,accessedthroughtheTasksproperty
Page 182
oftheSharedWorkspaceobject,tomanagetasksassignedtothememberswhoarecollaboratingonthedocument(s)inthesharedworkspace.
UsetheCreateNewmethodtocreateanewdocumentworkspaceandtoaddtheactivedocumenttotheworkspace.UsetheNameandURLpropertiestoreturninformationabouttheworkspace.
TheSharedWorkspaceobjectusesalocalcacheofobjectsandpropertiesfromtheserver.Thedevelopermayneedtoupdatethiscachebeforeperformingcertainoperations,ortosavecachedpropertychangesbacktotheserver.UsetheRefreshmethodoftheSharedWorkspaceobjecttorefreshthelocalcachefromtheserver,andtheLastRefreshedpropertytodeterminewhentherefreshoperationlasttookplace.UsetheSavemethodoftheSharedWorkspaceLinkandSharedWorkspaceTaskobjectsaftermodifyingtheirpropertieslocally,inordertouploadthechangestotheserver.
UsetheDisconnectmethodtodisconnectthelocalcopyoftheactivedocumentfromthesharedworkspace,whileleavingthesharedcopyintactintheworkspace.UsetheRemoveDocumentmethodtoremovetheshareddocumentfromthesharedworkspaceentirely.
Usersrequireappropriatepermissionstousetheobjects,propertiesandmethodsintheSharedWorkspaceobjecthierarchy.UsetheRoleargumentwhenaddingmemberstotheSharedWorkspaceMemberscollectiontospecifythesetofpermissionsspecifictoeachworkspacemember.
Thefollowingexampledisplaysthepropertiesofthesharedworkspacetowhichtheactivedocumentisconnected.
DimswsWorkspaceAsOffice.SharedWorkspace
DimstrSWSInfoAsString
SetswsWorkspace=ActiveWorkbook.SharedWorkspace
strSWSInfo=swsWorkspace.Name&vbCrLf&_
"-URL:"&swsWorkspace.URL&vbCrLf&_
"Thesharedworkspacecontains"&vbCrLf&_
"-Files:"&swsWorkspace.Files.Count&vbCrLf&_
"-Folders:"&swsWorkspace.Folders.Count&vbCrLf&_
"-Links:"&swsWorkspace.Links.Count&vbCrLf&_
"-Members:"&swsWorkspace.Members.Count&vbCrLf&_
"-Tasks:"&swsWorkspace.Tasks.Count&vbCrLf
MsgBoxstrSWSInfo,vbInformation+vbOKOnly,_
"SharedWorkspaceInformation"
Page 183
SetswsWorkspace=Nothing
WhenusingtheSharedWorkspaceobjectmodel,itispossibletocreateconditionswheretheSharedWorkspaceobjectcacheisnotsynchronizedwiththeuserinterfacedisplayedintheSharedWorkspacepaneoftheactivedocument.Forexample,iftheCreateNewmethodprogrammaticallyaddstheactivedocumenttoanewworkspacewhiletheSharedWorkspacepaneisopen,theSharedWorkspacepanewillcontinuetodisplaytheCreatebutton.Incircumstanceslikethese,iftheusermakesaselectionintheSharedWorkspacepanethatisnolongervalid,anerrorisraisedandarefreshoperationiscarriedouttosynchronizethedisplaywiththecurrentdocumentstateandsharedworkspacedata.
TheDocument,WorkbookandPresentationobjectsalsohaveaSyncpropertywhichreturnsaSyncobject.UsetheSyncobjectanditspropertiesandmethodstomanagethesynchronizationofthelocalandtheservercopiesoftheshareddocument.
Page 184
SharedWorkspaceFileObjectSharedWorkspace SharedWorkspaceFiles
SharedWorkspaceFile
TheSharedWorkspaceFileobjectrepresentsafilesavedinashareddocumentworkspace.MemberoftheSharedWorkspaceFilescollection.
Page 185
UsingtheSharedWorkspaceFileObject
UsetheSharedWorkspaceFileobjecttomanagedocumentsandfilessavedinasharedworkspace.
AlthoughtheSharedWorkspaceFileobjecthasaURLpropertythatreturnsthefile'scompletepathandfilename,itdoesnothaveaFileNameproperty.Useasimplefunctiontoextractthefilenamefromthefile'sURLasinthefollowingexample.AnadditionalsupportingfunctiondecodesescapedspacecharactersintheURL.
PrivateFunctionFilenameFromURL(FileURLAsString)AsString
DimintLastSeparatorAsInteger
FileURL=URLDecode(FileURL)
intLastSeparator=InStrRev(FileURL,"/")
FilenameFromURL=Right(FileURL,Len(FileURL)-intLastSeparator)
EndFunction
PrivateFunctionURLDecode(URLtoDecodeAsString)AsString
URLDecode=Replace(URLtoDecode,"%20","")
EndFunction
UsetheItem(Index)methodoftheSharedWorkspaceFilescollectiontoreturnaspecificSharedWorkspaceFileobject.
UsetheCreatedBy,CreatedDate,ModifiedBy,andModifiedDatepropertiestoreturninformationaboutthehistoryofeachfile.
Thefollowingexamplereturnsthenumberoffilesinthesharedworkspaceandinformationabouteachfile,usingthesupportingfunctionsshownabove.
DimswsFileAsOffice.SharedWorkspaceFile
DimstrFileInfoAsString
strFileInfo="Thesharedworkspacecontains"&_
ActiveWorkbook.SharedWorkspace.Files.Count&"File(s)."&vbCrLf
ForEachswsFileInActiveWorkbook.SharedWorkspace.Files
strFileInfo=strFileInfo&FilenameFromURL(swsFile.URL)&vbCrLf&_
"-URL:"&swsFile.URL&vbCrLf&_
"-Createdby:"&swsFile.CreatedBy&vbCrLf&_
"-Createdon:"&swsFile.CreatedDate&vbCrLf&_
"-Modifiedby:"&swsFile.ModifiedBy&vbCrLf&_
"-Modifiedon:"&swsFile.ModifiedDate&vbCrLf
Next
Page 186
MsgBoxstrFileInfo,vbInformation+vbOKOnly,_
"FilesinSharedWorkspace"
SetswsFile=Nothing
Page 187
SharedWorkspaceFolderObjectSharedWorkspace SharedWorkspaceFolders
SharedWorkspaceFolder
TheSharedWorkspaceFolderobjectrepresentsafolderinashareddocumentworkspace.MemberoftheSharedWorkspaceFolderscollection.
Page 188
UsingtheSharedWorkspaceFolderObject
UsetheSharedWorkspaceFolderobjecttomanagesubfolderswithinthemaindocumentlibraryfolderofasharedworkspace.
TheCountpropertyoftheSharedWorkspaceFolderscollectiondoesnotincludetheworkspace'smainfolderandreturns0(zero)ifnosubfoldershavebeencreated.
TheSharedWorkspaceFolderobjectdoesnotexposetheCreatedBy,CreatedDate,ModifiedBy,andModifiedDatepropertiesavailableontheSharedWorkspaceFile,SharedWorkspaceLink,andSharedWorkspaceTaskobjects.
UsetheItem(Index)methodoftheSharedWorkspaceFolderscollectiontoreturnaspecificSharedWorkspaceFolderobject.
UsetheFolderNamepropertytoreturnthenameofthesharedworkspacefolder.ThefollowingexamplereturnsthenameofthefirstsubfolderintheSharedWorkspaceFolderscollectionintheformatparentfoldername/foldername.
DimswsFolderAsSharedWorkspaceFolder
SetswsFolder=ActiveWorkbook.SharedWorkspace.Folders(1)
MsgBoxswsFolder.FolderName,vbInformation+vbOKOnly,"FolderName"
SetswsFolder=Nothing
Page 189
SharedWorkspaceLinkObjectSharedWorkspace SharedWorkspaceLinks
SharedWorkspaceLink
TheSharedWorkspaceLinkobjectrepresentsaURLlinksavedinashareddocumentworkspace.MemberoftheSharedWorkspaceLinkscollection.
Page 190
UsingtheSharedWorkspaceLinkObject
UsetheSharedWorkspaceLinkobjecttomanagelinkstoadditionaldocumentsandinformationofinteresttothememberswhoarecollaboratingonthedocument(s)inthesharedworkspace.
UsetheItem(Index)methodoftheSharedWorkspaceLinkscollectiontoreturnaspecificSharedWorkspaceLinkobject.
UsetheDescriptionpropertytosetthelinkdescriptionthatwillappearontheLinkstaboftheSharedWorkspacepaneandontheworkspacewebpage.UsetheUrlpropertytosetthedestinationaddressofthelink.UsetheNotespropertytosupplyadditionalinformationaboutthelink.
UsetheSavemethodtouploadchangestotheserverafteryoumodifypropertiesoftheSharedWorkspaceLinkobject.
UsetheCreatedBy,CreatedDate,ModifiedBy,andModifiedDatepropertiestoreturninformationaboutthehistoryofeachlink.
ThefollowingexamplemodifiesthefirstlinkinthesharedworkspacetopointtotheMicrosoftDeveloperNetworkhomepage,thenuploadsthechangestotheserver.
DimswsLinkAsOffice.SharedWorkspaceLink
SetswsLink=ActiveWorkbook.SharedWorkspace.Links(1)
WithswsLink
.Description="MSDNHomePage"
.URL="http://msdn.microsoft.com/"
.Notes="Myfavoritesitefordevelopers!"
.Save
EndWith
SetswsLink=Nothing
Page 192
SharedWorkspaceMemberObjectSharedWorkspace SharedWorkspaceMembers
SharedWorkspaceMember
TheSharedWorkspaceMemberobjectrepresentsauserwhohasrightsinashareddocumentworkspace.MemberoftheSharedWorkspaceMemberscollection.
Page 193
UsingtheSharedWorkspaceMemberObject
UsetheSharedWorkspaceMemberobjecttomanageuserswhohaverightstoparticipateinasharedworkspaceandtocollaborateontheshareddocument(s)savedintheworkspace.
TheRolespecifiedwhentheuserisaddedasamemberoftheworkspace(forexample,"Reader"or"Contributor")determinesthatuser'srightsintheworkspaceandcannotbeaccessedormodifiedlaterthroughpropertiesoftheSharedWorkspaceMemberobject.
UsetheItem(Index)methodoftheSharedWorkspaceMemberscollectiontoreturnaspecificSharedWorkspaceMemberobject.
UsetheSharedWorkspaceMemberobject's3distinctnamepropertiestoretrieveidentifyinginformationaboutthemember.
theNamepropertyreturnsthemembersdisplaynameorfriendlyname;theEmailpropertyreturnsthemember'semailaddress;and,theDomainNamepropertyreturnsthemember'sdomainandusernameintheformatdomain\user.
Thefollowingexampledisplaysthenumberofmembersintheactivedocument'ssharedworkspace,alongwiththeirnames,domainusernames,andemailaddresses.
DimswsMemberAsOffice.SharedWorkspaceMember
DimstrMemberInfoAsString
strMemberInfo="Thesharedworkspacecontains"&_
ActiveWorkbook.SharedWorkspace.Members.Count&"member(s)."&vbCrLf
IfActiveWorkbook.SharedWorkspace.Members.Count>0Then
ForEachswsMemberInActiveWorkbook.SharedWorkspace.Members
strMemberInfo=strMemberInfo&swsMember.Name&vbCrLf&_
"-"&swsMember.DomainName&vbCrLf&_
"-"&swsMember.Email&vbCrLf
Next
EndIf
MsgBoxstrMemberInfo,vbInformation+vbOKOnly,_
"MembersinSharedWorkspace"
SetswsMember=Nothing
Page 195
SharedWorkspaceTaskObjectSharedWorkspace SharedWorkspaceTasks
SharedWorkspaceTask
TheSharedWorkspaceTaskobjectrepresentsataskinashareddocumentworkspace.MemberoftheSharedWorkspaceTaskscollection.
Page 196
UsingtheSharedWorkspaceTaskObject
UsetheSharedWorkspaceTaskobjecttomanagetasksassignedtothememberswhoarecollaboratingonthedocument(s)inthesharedworkspace.
UsetheItem(Index)methodoftheSharedWorkspaceTaskscollectiontoreturnaspecificSharedWorkspaceTaskobject.
UsetheTitlepropertytosetthetextofthetaskthatwillappearontheTaskstaboftheSharedWorkspacetaskpaneandonthesharedworkspaceWebpage.UsetheDescriptionpropertytosupplyadditionalinformationaboutthetask.
AssignthetasktoamemberoftheworkspaceusingtheAssignedTopropertyandthemember'sdomainusername.SpecifyaduedateforthetaskusingtheDueDateproperty.
UsetheenumerationsfortaskPriorityandStatustoindicatetherelativeimportanceofthetaskandtoupdatethetask'sstatus.
UsetheSavemethodtouploadchangestotheserverafteryoumodifypropertiesoftheSharedWorkspaceTaskobject.
UsetheCreatedBy,CreatedDate,ModifiedBy,andModifiedDatepropertiestoreturninformationaboutthehistoryofeachtask.
Thefollowingexamplereturnsthenumberoftasksinthesharedworkspaceandinformationabouteachtask.
DimswsTaskAsOffice.SharedWorkspaceTask
DimstrTaskInfoAsString
strTaskInfo="Thesharedworkspacecontains"&_
ActiveWorkbook.SharedWorkspace.Tasks.Count&"Task(s)."&vbCrLf
ForEachswsTaskInActiveWorkbook.SharedWorkspace.Tasks
strTaskInfo=strTaskInfo&swsTask.Title&vbCrLf&_
"-Description:"&swsTask.Description&vbCrLf&_
"-Assignedto:"&swsTask.AssignedTo&vbCrLf&_
"-Duedate:"&swsTask.DueDate&vbCrLf&_
"-Priority:"&swsTask.Priority&vbCrLf&_
"-Status:"&swsTask.Status&vbCrLf
Next
MsgBoxstrTaskInfo,vbInformation+vbOKOnly,_
Page 197
"TasksinSharedWorkspace"
SetswsTask=Nothing
Page 198
SignatureObjectSignatureSet Signature
Correspondstoadigitalsignaturethatisattachedtoadocument.SignatureobjectsarecontainedintheSignatureSetcollectionoftheDocumentobject.
Page 199
UsingtheSignatureobject
YoucanaddaSignatureobjecttoaSignatureSetcollectionusingtheAddmethodandyoucanreturnanexistingmemberusingtheItemmethod.ToremoveaSignaturefromaSignatureSetcollection,usetheDeletemethodoftheSignatureobject.
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandpassthisfunctionthenameofacertificateissuerandthenameofacertificatesignerthatmatchtheIssuedByandIssuedTofieldsofadigitalcertificateintheDigitalCertificatesdialogbox.Thisexamplewilltesttomakesurethatthedigitalsignaturethattheuserselectsmeetscertaincriteria,suchasnothavingexpired,beforethenewsignatureiscommittedtothedisk.
FunctionAddSignature(ByValstrIssuerAsString,_
strSignerAsString)AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
'TestseveralpropertiesbeforecommitingtheSignatureobjecttodisk.
Ifsig.Issuer=strIssuerAnd_
sig.Signer=strSignerAnd_
sig.IsCertificateExpired=FalseAnd_
sig.IsCertificateRevoked=FalseAnd_
sig.IsValid=TrueThen
MsgBox"Signed"
AddSignature=True
'Otherwise,removetheSignatureobjectfromtheSignatureSetcollection.
Else
sig.Delete
MsgBox"Notsigned"
AddSignature=False
Page 200
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 201
SmartDocumentObjectSmartDocument
TheSmartDocumentpropertyoftheMicrosoftOfficeWord2003DocumentobjectandtheMicrosoftOfficeExcel2003WorkbookobjectreturnsaSmartDocumentobject.
Page 202
UsingtheSmartDocumentObject
UsetheSmartDocumentobjecttomanagetheXMLexpansionpackattachedtotheactivedocument.
UsetheSmartDocumentobject'sSolutionIDandtheSolutionUrlpropertiestoretrieveinformationabouttheXMLexpansionpackattachedtotheactivedocumentorworkbook.UsethePickSolutionmethodtoallowtheusertoselectanavailableXMLexpansionpackfromalisttoattachtotheactivedocumentorworkbook.UsetheRefreshPanemethodtorefreshthesmartdocument'sDocumentActionstaskpane.
TheSmartDocumentobjectmodelisavailablewhetherornotadocumenthasanXMLexpansionpackattached.TheSmartDocumentpropertyoftheDocumentorWorkbookobjectsdoesnotreturnNothingwhentheactivedocumenthasnoXMLexpansionpackattached.ExaminetheSolutionIDpropertytodeterminewhethertheactivedocumenthasanXMLexpansionpackattached.
Page 204
SyncObjectSync
TheSyncpropertyoftheMicrosoftOfficeWord2003Documentobject,theMicrosoftOfficeExcel2003Workbookobject,andtheMicrosoftOfficePowerPoint2003PresentationobjectreturnsaSyncobject.
Page 205
UsingtheSyncObject
UsetheSyncobjecttomanagethesynchronizationofthelocalandservercopiesofashareddocumentstoredinaWindowsSharePointServicesdocumentworkspace.TheStatuspropertyreturnsimportantinformationaboutthecurrentstateofsynchronization.UsetheGetUpdatemethodtorefreshthesyncstatus.UsetheLastSyncTime,ErrorType,andWorkspaceLastChangedBypropertiestoreturnadditionalinformation.
SeetheStatusPropertyforadditionalinformationonthedifferencesandconflictsthatcanexistbetweenthelocalandservercopiesofshareddocuments.
UsethePutUpdatemethodtosavelocalchangestotheserver.Closeandre-openthedocumenttoretrievethelatestversionfromtheserverwhennolocalchangeshavebeenmade.UsetheResolveConflictmethodtoresolvedifferencesbetweenthelocalandtheservercopies,ortheOpenVersionmethodtoopenadifferentversionalongsidethecurrentlyopenlocalversionofthedocument.
TheGetUpdate,PutUpdate,andResolveConflictmethodsoftheSyncobjectdonotreturnstatuscodesbecausetheycompletetheirtasksasynchronously.TheSyncobjectprovidesimportantstatusinformationthroughasingleevent,whichthedevelopercanaccessthroughthefollowingapplication-specificevents:
inWord,throughtheSynceventoftheDocumentobjectortheDocumentSynceventoftheApplicationobject;inExcel,throughtheSynceventoftheWorkbookobjectortheWorkbookSynceventoftheApplicationobject;inPowerPoint,throughthePresentationSynceventoftheApplicationobject.
TheSynceventdescribedabovereturnsanmsoSyncEventTypevalue.
MsoSyncEventTypecanbeoneofthefollowingmsoSyncEventTypeconstants.msoSyncEventDownloadInitiated(0)msoSyncEventDownloadSucceeded(1)msoSyncEventDownloadFailed(2)msoSyncEventUploadInitiated(3)
Page 206
msoSyncEventUploadSucceeded(4)msoSyncEventUploadFailed(5)msoSyncEventDownloadNoChange(6)msoSyncEventOffline(7)
TheSyncobjectmodelisavailablewhethersharingandsynchronizationareenabledordisabledontheactivedocument.TheSyncpropertyoftheDocument,WorkbookandPresentationobjectsdoesnotreturnNothingwhentheactivedocumentisnotsharedorsynchronizationisnotenabled.UsetheStatuspropertytodeterminewhetherthedocumentissharedandwhethersynchronizationisenabled.
Notalldocumentsynchronizationproblemsraisetrappablerun-timeerrors.AfterusingthemethodsoftheSyncobject,it'sagoodideatochecktheStatusproperty;iftheStatuspropertyismsoSyncStatusError,checktheErrorTypepropertyforadditionalinformationonthetypeoferrorthathasoccurred.
Inmanycircumstances,thebestwaytoresolveanerrorconditionistocalltheGetUpdatemethod.Forexample,ifacalltoPutUpdateresultsinanerrorcondition,thenacalltoGetUpdatewillresetthestatustomsoSyncStatusLocalChanges.
Page 207
Example
ThefollowingexampledemonstratesvariousmethodsoftheSyncobjectbasedonthestatusoftheactivedocument.
DimobjSyncAsOffice.Sync
DimstrStatusAsString
SetobjSync=ActiveDocument.Sync
IfobjSync.Status>msoSyncStatusNoSharedWorkspaceThen
SelectCaseobjSync.Status
CasemsoSyncStatusConflict
objSync.ResolveConflictmsoSyncConflictMerge
ActiveDocument.Save
objSync.ResolveConflictmsoSyncConflictClientWins
strStatus="Conflictresolvedbymergingchanges."
CasemsoSyncStatusError
strStatus="Lasterrortype:"&objSync.ErrorType
CasemsoSyncStatusLatest
strStatus="Documentcopiesalreadyinsync."
CasemsoSyncStatusLocalChanges
objSync.PutUpdate
strStatus="Localchangessavedtoserver."
CasemsoSyncStatusNewerAvailable
objSync.GetUpdate
strStatus="Localcopyupdatedfromserver."
CasemsoSyncStatusSuspended
objSync.Unsuspend
strStatus="Synchronizationresumed."
EndSelect
Else
strStatus="Notasharedworkspacedocument."
EndIf
MsgBoxstrStatus,vbInformation+vbOKOnly,"SyncInformation"
SetobjSync=Nothing
Page 208
UserPermissionObjectPermission UserPermission
TheUserPermissionobjectassociatesasetofpermissionsontheactivedocumentwithasingleuserandanoptionalexpirationdate.Representsamemberoftheactivedocument'sPermissioncollection.
Page 209
UsingtheUserPermissionObject
UsetheAddmethodofthePermissionobjecttograntspecificpermissionsontheactivedocumenttoanewuser,withanoptionalexpirationdate.UsetheRemovemethodoftheUserPermissionobjecttoremoveauserandtheuser'spermissions.
Whilesomepermissionsgrantedthroughtheuserinterface(suchasmsoPermissionPrint)applytoallusers,youcanusetheUserPermissionobjecttoassignthemonaper-userbasiswithper-userexpirationdates.
Page 210
Example
Thefollowingexampledetermineswhethertheactivedocumenthasrestrictedpermissions,thenlistsusersandtheirassignedpermissionsbyreturningtheUserID,Permission,andExpirationDatepropertiesofeachUserPermissioninthedocument'sPermissioncollection.
DimirmPermissionAsOffice.Permission
DimirmUserPermAsOffice.UserPermission
DimstrIRMInfoAsString
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
ForEachirmUserPermInirmPermission
strIRMInfo=strIRMInfo&irmUserPerm.UserId&vbCrLf&_
"-Permissions:"&irmUserPerm.Permission&vbCrLf&_
"-ExpirationDate:"&irmUserPerm.ExpirationDate&vbCrLf
Next
MsgBoxstrIRMInfo,_
vbInformation+vbOKOnly,"IRMInformation"
Else
MsgBox"Thisdocumentisnotrestricted.",_
vbInformation+vbOKOnly,"IRMInformation"
EndIf
SetirmUserPerm=Nothing
SetirmPermission=Nothing
Page 212
WebPageFontObjectWebPageFonts WebPageFont
RepresentsthedefaultfontusedwhendocumentsaresavedasWebpagesforaparticularcharacterset.
UsingtheWebPageFontObject
UsetheWebPageFontobjecttodescribetheproportionalfont,proportionalfontsize,fixed-widthfont,andfixed-widthfontsizeforanyavailablecharacterset.
Thefollowingcharactersetsaresupported.msoCharacterSetArabicmsoCharacterSetCyrillicmsoCharacterSetEnglishWesternEuropeanOtherLatinScriptmsoCharacterSetGreekmsoCharacterSetHebrewmsoCharacterSetJapanesemsoCharacterSetKoreanmsoCharacterSetMultilingualUnicodemsoCharacterSetSimplifiedChinesemsoCharacterSetThaimsoCharacterSetTraditionalChinesemsoCharacterSetVietnamese
ThefollowingexamplesetstheproportionalfontandproportionalfontsizefortheWebPageFontobjectmyFont.
WithmyFont
ProportionalFont=Verdana
ProportionalFontSize=14
Page 215
ActivateWizardMethodSomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ResumesorsuspendsOfficeAssistantHelpduringacustomwizard.
NoteYoushouldusethismethodonlywiththeStartWizardmethod.
expression.ActivateWizard(WizardID,Act,Animation)
expressionRequired.AnexpressionthatreturnsanAssistantobject.
WizardIDRequiredLong.ThenumberreturnedbytheStartWizardmethod.
ActRequiredMsoWizardActType.SpecifiesthechangetotheOfficeAssistantHelpsession.
MsoWizardActTypecanbeoneoftheseMsoWizardActTypeconstants.msoWizardActActivemsoWizardActInactivemsoWizardActResumemsoWizardActSuspend
AnimationOptionalVariant.TheanimationtheOfficeAssistantperformswhenitissuspendedorresumed.
Page 216
Example
ThisexamplesuspendsthewizardsessionthatwasstartedwiththeStartWizardmethod.ThevariablelHelpForWizwassettothereturnvalueoftheStartWizardmethod.
Assistant.ActivateWizardWizardID:=lHelpForWiz,_
Act:=msoWizardActSuspend,Animation:=msoAnimationGoodbye
Page 218
AddMethodAddmethodasitappliestotheAnswerWizardFilesobject.
Createsanewreference(aStringvalue)toanAnswerWizardfileandaddsittotheAnswerWizardFilescollection.
expression.Add(FileName)
expressionRequired.AnexpressionthatreturnsanAnswerWizardFilescollection.
FileNameRequiredString.ThefullyqualifiedpathtothespecifiedAnswerWizardfile.
AddmethodasitappliestotheCommandBarsobject.
Createsanewcommandbarandaddsittothecollectionofcommandbars.ReturnsaCommandBarobject.
expression.Add(Name,Position,MenuBar,Temporary)
expressionRequired.AnexpressionthatreturnsaCommandBarsobject.
NameOptionalVariant.Thenameofthenewcommandbar.Ifthisargumentisomitted,adefaultnameisassignedtothecommandbar(suchasCustom1).
PositionOptionalVariant.Thepositionortypeofthenewcommandbar.CanbeoneoftheMsoBarPositionconstantslistedinthefollowingtable.
Constant DescriptionmsoBarLeft,msoBarTop,msoBarRight,msoBarBottom
Indicatestheleft,top,right,andbottomcoordinatesofthenewcommandbar
msoBarFloating Indicatesthatthenewcommandbarwon'tbedockedIndicatesthatthenewcommandbarwillbe
Page 219
msoBarPopup ashortcutmenu
msoBarMenuBar Macintoshonly
MenuBarOptionalVariant.Truetoreplacetheactivemenubarwiththenewcommandbar.ThedefaultvalueisFalse.
TemporaryOptionalVariant.Truetomakethenewcommandbartemporary.Temporarycommandbarsaredeletedwhenthecontainerapplicationisclosed.ThedefaultvalueisFalse.
AddmethodasitappliestotheCommandBarControlsobject.
CreatesanewCommandBarControlobjectandaddsittothecollectionofcontrolsonthespecifiedcommandbar.
expression.Add(Type,Id,Parameter,Before,Temporary)
expressionRequired.AnexpressionthatreturnsaCommandBarControlsobject.
TypeOptionalVariant.Thetypeofcontroltobeaddedtothespecifiedcommandbar.CanbeoneofthefollowingMsoControlTypeconstants:msoControlButton,msoControlEdit,msoControlDropdown,msoControlComboBox,ormsoControlPopup.
IdOptionalVariant.Anintegerthatspecifiesabuilt-incontrol.Ifthevalueofthisargumentis1,orifthisargumentisomitted,ablankcustomcontrolofthespecifiedtypewillbeaddedtothecommandbar.
ParameterOptionalVariant.Forbuilt-incontrols,thisargumentisusedbythecontainerapplicationtorunthecommand.Forcustomcontrols,youcanusethisargumenttosendinformationtoVisualBasicprocedures,oryoucanuseittostoreinformationaboutthecontrol(similartoasecondTagpropertyvalue).
BeforeOptionalVariant.Anumberthatindicatesthepositionofthenewcontrolonthecommandbar.Thenewcontrolwillbeinsertedbeforethecontrolatthisposition.Ifthisargumentisomitted,thecontrolisaddedattheendofthespecifiedcommandbar.
Page 220
TemporaryOptionalVariant.Truetomakethenewcontroltemporary.Temporarycontrolsareautomaticallydeletedwhenthecontainerapplicationisclosed.ThedefaultvalueisFalse.
AddmethodasitappliestotheDocumentPropertiesobject.
Createsanewcustomdocumentproperty.YoucanonlyaddanewdocumentpropertytothecustomDocumentPropertiescollection.
expression.Add(Name,LinkToContent,Type,Value,LinkSource)
expressionRequired.ThecustomDocumentPropertiesobject.
NameRequiredString.Thenameoftheproperty.
LinkToContentRequiredBoolean.Specifieswhetherthepropertyislinkedtothecontentsofthecontainerdocument.IfthisargumentisTrue,theLinkSourceargumentisrequired;ifit'sFalse,thevalueargumentisrequired.
TypeOptionalVariant.Thedatatypeoftheproperty.CanbeoneofthefollowingMsoDocPropertiesconstants:msoPropertyTypeBoolean,msoPropertyTypeDate,msoPropertyTypeFloat,msoPropertyTypeNumber,ormsoPropertyTypeString.
ValueOptionalVariant.Thevalueoftheproperty,ifit'snotlinkedtothecontentsofthecontainerdocument.Thevalueisconvertedtomatchthedatatypespecifiedbythetypeargument,ifitcan'tbeconverted,anerroroccurs.IfLinkToContentisTrue,theValueargumentisignoredandthenewdocumentpropertyisassignedadefaultvalueuntilthelinkedpropertyvaluesareupdatedbythecontainerapplication(usuallywhenthedocumentissaved).
LinkSourceOptionalVariant.IgnoredifLinkToContentisFalse.Thesourceofthelinkedproperty.Thecontainerapplicationdetermineswhattypesofsourcelinkingyoucanuse.
Page 221
Remarks
IfyouaddacustomdocumentpropertytotheDocumentPropertiescollectionthat’slinkedtoagivenvalueinaMicrosoftOfficedocument,youmustsavethedocumenttoseethechangetotheDocumentPropertyobject.
AddmethodasitappliestotheFileDialogFiltersobject.
AddsanewfilefiltertothelistoffiltersintheFilesoftypedropdownlistboxintheFiledialogbox.ReturnsaFileDialogFilterobjectthatrepresentsthenewlyaddedfilefilter.
expression.Add(Description,Extensions,Position)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
DescriptionRequiredString.Thetextrepresentingthedescriptionofthefileextensionyouwanttoaddtothelistoffilters.
ExtensionsRequiredString.Thetextrepresentingthefileextensionyouwanttoaddtothelistoffilters.Morethanoneextensionmaybespecifiedandeachmustbeseparatedbyasemi-colon(;).Forexample,theExtensionsargumentcanbeassignedtothestring:"*.txt;*.htm".NoteParenthesesdonotneedtobeaddedaroundtheextensions.Officewillautomaticallyaddparenthesesaroundtheextensionsstringwhenthedescriptionandextensionsstringsareconcatenatedintoonefilefilteritem.
PositionOptionalVariant.Anumberthatindicatesthepositionofthenewcontrolinthefilterlist.Thenewfilterwillbeinsertedbeforethefilteratthisposition.Ifthisargumentisomitted,thefilterisaddedattheendofthelist.
Page 222
Remarks
Eachfilterinalistismadeupoftwoparts:thefileextension(e.g..txt)andthetextdescriptionofthefileextension(e.g.TextFiles).Together,thefilefilterwouldappearintheFilesoftypedropdownlistboxas:TextFiles(*.txt).
Notethatwhenafilterisaddedtothelist,thedefaultfiltersarenotremoved.
FiltersareonlydisplayedwhentheWindowsoptionischecked.
IfPositionisinvalid,anoutofrangeruntimeerrorisdisplayed.IftheDescriptionandExtensionsvalueareinvalid,aruntimeerror(parse)isdisplayed.
Folderpickerdialogsdonothavefilters,therefore,filtermethodsdonotapplytothefolderpicker.
AddmethodasitappliestotheFileTypesobject.
Addsanewfiletypetoafilesearch.
expression.Add(FileType)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
FileTypeRequiredMsoFileType.Specifiesthetypeoffileforwhichtosearch.
MsoFileTypecanbeoneoftheseMsoFileTypeconstants.msoFileTypeAllFilesmsoFileTypeBindersmsoFileTypeCalendarItemmsoFileTypeContactItemmsoFileTypeCustommsoFileTypeDatabasesmsoFileTypeDataConnectionFilesmsoFileTypeDesignerFiles
Page 223
msoFileTypeDocumentImagingFilesmsoFileTypeExcelWorkbooksmsoFileTypeJournalItemmsoFileTypeMailItemmsoFileTypeNoteItemmsoFileTypeOfficeFilesmsoFileTypeOutlookItemsmsoFileTypePhotoDrawFilesmsoFileTypePowerPointPresentationsmsoFileTypeProjectFilesmsoFileTypePublisherFilesmsoFileTypeTaskItemmsoFileTypeTemplatesmsoFileTypeVisioFilesmsoFileTypeWebPagesmsoFileTypeWordDocuments
AddmethodasitappliestothePropertyTestsobject.
AddsaPropertyTestobjecttothePropertyTestscollection.
expression.Add(Name,Condition,Value,SecondValue,Connector)
expressionRequired.AnexpressionthatreturnsaPropertyTestsobject.
NameRequiredString.Thenameofthepropertycriterion.ThenamecorrespondstoavalueinthePropertyboxintheFinddialogbox,whichyouopenfromtheToolsmenuintheapplication'sOpendialogbox(Filemenu).
ConditionRequiredMsoCondition.Theconditionofthesearchcriteria.
MsoConditioncanbeoneoftheseMsoConditionconstants.msoConditionAnyNumberBetweenmsoConditionAnytimemsoConditionAnytimeBetweenmsoConditionAtLeast
Page 224
msoConditionAtMostmsoConditionBeginsWithmsoConditionDoesNotEqualmsoConditionEndsWithmsoConditionEqualsmsoConditionEqualsCompletedmsoConditionEqualsDeferredmsoConditionEqualsHighmsoConditionEqualsInProgressmsoConditionEqualsLowmsoConditionEqualsNormalmsoConditionEqualsNotStartedmsoConditionEqualsWaitingForSomeoneElsemsoConditionFileTypeAllFilesmsoConditionFileTypeBindersmsoConditionFileTypeCalendarItemmsoConditionFileTypeContactItemmsoConditionFileTypeDatabasesmsoConditionFileTypeDataConnectionFilesmsoConditionFileTypeDesignerFilesmsoConditionFileTypeDocumentImagingFilesmsoConditionFileTypeExcelWorkbooksmsoConditionFileTypeJournalItemmsoConditionFileTypeMailItemmsoConditionFileTypeNoteItemmsoConditionFileTypeOfficeFilesmsoConditionFileTypeOutlookItemsmsoConditionFileTypePhotoDrawFilesmsoConditionFileTypePowerPointPresentationsmsoConditionFileTypeProjectFilesmsoConditionFileTypePublisherFilesmsoConditionFileTypeTaskItemmsoConditionFileTypeTemplates
Page 225
msoConditionFileTypeVisioFilesmsoConditionFileTypeWebPagesmsoConditionFileTypeWordDocumentsmsoConditionFreeTextmsoConditionIncludesmsoConditionIncludesFormsOfmsoConditionIncludesNearEachOthermsoConditionIncludesPhrasemsoConditionInTheLastmsoConditionInTheNextmsoConditionIsExactlymsoConditionIsNomsoConditionIsNotmsoConditionIsYesmsoConditionLastMonthmsoConditionLastWeekmsoConditionLessThanmsoConditionMoreThanmsoConditionNextMonthmsoConditionNextWeekmsoConditionNotEqualToCompletedmsoConditionNotEqualToDeferredmsoConditionNotEqualToHighmsoConditionNotEqualToInProgressmsoConditionNotEqualToLowmsoConditionNotEqualToNormalmsoConditionNotEqualToNotStartedmsoConditionNotEqualToWaitingForSomeoneElsemsoConditionOnmsoConditionOnOrAftermsoConditionOnOrBeforemsoConditionThisMonthmsoConditionThisWeek
Page 226
msoConditionTodaymsoConditionTomorrowmsoConditionYesterday
ValueOptionalVariant.Thevalueofthesearchcriterion.
SecondValueOptionalVariant.Anuppervalueforthesearchrange.YoucanusethisargumentonlyifConditionismsoConditionAnyTimeBetweenormsoConditionAnyNumberBetween.
ConnectorOptionalMsoConnector.Specifiesthewaytwosearchcriteriaarecombined.
MsoConnectorcanbeoneoftheseMsoConnectorconstants.msoConnectorAnddefaultmsoConnectorOr
AddmethodasitappliestotheNewFileobject.
AddsanewitemtotheNewItemtaskpane.ReturnsaBoolean.Trueiftheitemwassuccessfullyadded.
expression.Add(FileName,Section,DisplayName,Action)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
FileNameRequiredString.Thenameofthefiletoaddtothelistoffilesonthetaskpane.
SectionOptionalVariant.Thesectiontowhichtoaddthefile.CanbeanymsoFileNewSectionconstant.
DisplayNameOptionalVariant.Thetexttodisplayinthetaskpane.
ActionOptionalVariant.Theactiontotakewhenauserclicksontheitem.CanbeanymsoFileNewActionconstant.
AddmethodasitappliestotheODSOFiltersobject.
Page 227
AddsanewfiltertotheODSOFilterscollection.
expression.Add(Column,Comparison,Conjunction,bstrCompareTo,DeferUpdate)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
ColumnRequiredString.Thenameofthetableinthedatasource.
ComparisonRequiredMsoFilterComparison.Howthedatainthetableisfiltered.
MsoFilterComparisoncanbeoneoftheseMsoFilterComparisonconstants.msoFilterComparisonContainsmsoFilterComparisonEqualmsoFilterComparisonGreaterThanmsoFilterComparisonGreaterThanEqualmsoFilterComparisonIsBlankmsoFilterComparisonIsNotBlankmsoFilterComparisonLessThanmsoFilterComparisonLessThanEqualmsoFilterComparisonNotContainsmsoFilterComparisonNotEqual
ConjunctionRequiredMsoFilterConjunction.DetermineshowthisfilterrelatestootherfiltersintheODSOFiltersobject.
MsoFilterConjunctioncanbeoneoftheseMsoFilterConjunctionconstants.msoFilterConjunctionAndmsoFilterConjunctionOr
bstrCompareToOptionalString.IftheComparisonargumentissomethingotherthanmsoFilterComparisonIsBlankormsoFilterComparisonIsNotBlank,astringtowhichthedatainthetableiscompared.
DeferUpdateOptionalBoolean.DefaultisFalse.
Page 228
AddmethodasitappliestothePermissionobject.
Createsanewsetofpermissionsontheactivedocumentforthespecifieduser.ReturnsaUserPermissionobject.
expression.Add(UserID,Permission,ExpirationDate)
expressionRequired.AnexpressionthatreturnsaPermissionobject.
UserIDRequiredString.Theemailaddress([email protected] )oftheusertowhompermissionsontheactivedocumentarebeinggranted.
PermissionOptionalmsoPermission.Thepermissionsontheactivedocumentthatarebeinggrantedtothespecifieduser.
MsoPermissioncanbeoneoracombinationoftheseMsoPermissionconstants.msoPermissionChangemsoPermissionEditmsoPermissionExtractmsoPermissionFullControlmsoPermissionObjModelmsoPermissionPrintmsoPermissionReadmsoPermissionSavemsoPermissionView
ExpirationDateOptionalDate.Theexpirationdateforthepermissionsthatarebeinggranted.
AddmethodasitappliestotheScriptsobject.
AddsaScriptobjecttotheScriptscollectionofoneofthefollowingobjects:aDocumentorRangeobjectinMicrosoftWord;aWorksheetorChartobjectinMicrosoftExcel;oraSlide,SlideRange,slideMaster,ortitleMasterobjectinMicrosoftPowerPoint.ReturnsaScriptobject.
Page 229
expression.Add(Anchor,Location,Language,Id,Extended,ScriptText)
expressionRequired.TheScriptscollection.
AnchorOptionalRange(MicrosoftExcelonly).TheAnchorargumentacceptsanExcelRangeobject,whichspecifiestheplacementofthescriptanchoronanExcelWorksheet.YoucannotinsertscriptanchorsintoExcelcharts.
LocationOptionalMsoScriptLocation.Specifiesthelocationofthescriptanchorinadocument.Ifyou’vespecifiedtheAnchorargument,theLocationargumentisn’tused;thelocationoftheAnchorargumentdeterminesthelocationofthescriptanchor.
MsoScriptLocationcanbeoneoftheseMsoScriptLocationconstants.msoScriptLocationInBodydefaultmsoScriptLocationInHead
LanguageOptionalMsoScriptLanguage.Specifiesthescriptlanguage.
MsoScriptLanguagecanbeoneoftheseMsoScriptLanguageconstants.msoScriptLanguageASPmsoScriptLanguageJavamsoScriptLanguageOthermsoScriptLanguageVisualBasicdefault
IdOptionalString.TheIDofthe<SCRIPT>taginHTML.TheIdargumentspecifiesanSGMLidentifierusedfornamingelements.Valididentifiersincludeanystringthatbeginswithaletterandiscomposedofalphanumericcharacters;thestringcanalsoincludetheunderscorecharacter(_).TheIDmustbeuniquewithintheHTMLdocument.ThisparameterisexportedastheIDattributeinthe<SCRIPT>tag.
ExtendedOptionalString.Specifiesattributesthataretobeaddedtothe<SCRIPT>tag(LANGUAGEandIDattributesareexportedthroughtheLanguageandIdparametersandshouldnotbeexportedthroughtheExtendedparameter).Thedefaultistheemptystring.Attributesareseparatedbyspaces,thesameasinHTML.TheMicrosoftOfficehostapplicationdoesn’tprovideanymeansofcheckingthesyntaxofpassedattributes.
Page 230
ScriptTextOptionalString.Specifiesthetextcontainedinablockofscript.Thedefaultistheemptystring.TheMicrosoftOfficehostapplicationdoesn’tcheckthesyntaxofthescript.
Page 231
Remarks
Ashapeassociatedwithascriptblockisn’texportedorprintedasashapeinHTML;onlythescriptblockgetsexported.
YoucannotusetheAddmethodtoaddascriptanchortoaPowerPointsliderangethatcontainsmorethanoneslide.
AddmethodasitappliestotheSearchFoldersobject.
Addsasearchfoldertoafilesearch.
expression.Add(ScopeFolder)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
ScopeFolderRequiredScopeFolderobject.Thefoldertoaddtothesearch.
AddmethodasitappliestotheSignatureSetobject.
ReturnsaSignatureobjectthatrepresentsanewe-mailsignature.
expression.Add
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
AddmethodasitappliestotheSharedWorkspaceFilesobject.
Addsafiletothedocumentlibraryinasharedworkspace.ReturnsaSharedWorkspaceFileobject.
expression.Add(FileName,ParentFolder,OverwriteIfFileAlreadyExists,KeepInSync)
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceFilesobject.
FileNameRequiredString.Thepathandfilenameofthefiletobeaddedto
Page 232
thecurrentsharedworkspace.
ParentFolderOptionalSharedWorkspaceFolder.Thesubfolderinwhichtoplacethefile,ifnotthemaindocumentlibraryfolderwithinthesharedworkspace.Addthefiletothemaindocumentlibraryfolderbyleavingthisoptionalargumentempty.
OverwriteIfFileAlreadyExistsOptionalBoolean.Truetooverwriteanexistingfilebythesamename.DefaultisFalse.
KeepInSyncOptionalBoolean.Truetokeepthelocalcopyofthedocumentsynchronizedwiththecopyinthesharedworkspace.DefaultisFalse.
AddmethodasitappliestotheSharedWorkspaceFoldersobject.
Addsafoldertothedocumentlibraryinasharedworkspace.ReturnsaSharedWorkspaceFolderobject.
expression.Add(FolderName,ParentFolder)
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceFoldersobject.
FolderNameRequiredString.Thenameofthefoldertobeaddedtothecurrentsharedworkspace.
ParentFolderOptionalSharedWorkspaceFolder.Thesubfolderinwhichtoplacethenewfolder,ifnotthemaindocumentlibraryfolderwithinthesharedworkspace.Addthefoldertothemaindocumentlibraryfolderbyleavingthisoptionalargumentempty.
AddmethodasitappliestotheSharedWorkspaceLinksobject.
Addsalinktothelistoflinksinasharedworkspace.ReturnsaSharedWorkspaceLinkobject.
expression.Add(URL,Description,Notes)
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceLinksobject.
Page 233
URLRequiredString.TheURLofthewebsitetowhichalinkisbeingadded.
DescriptionOptionalString.Optionaldescriptionofthelink.
NotesOptionalString.Optionalnotesaboutthelink.
AddmethodasitappliestotheSharedWorkspaceMembersobject.
Addsamembertothelistofmembersinasharedworkspace.ReturnsaSharedWorkspaceMemberobject.
expression.Add(Email,DomainName,DisplayName,Role)
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceMembersobject.
EmailRequiredString.Thenewmember'semailaddressintheformatuser@domain.com.Raisesanerroriftheuserisnotavalidcandidateformembershipinthesharedworkspace.
DomainNameRequiredString.Thenewmember'sWindowsusernameintheformatdomain\user.
DisplayNameRequiredString.Thefriendlynametodisplayforthenewmember.
RoleOptionalString.Anoptionalrolethatdeterminesthetasksthenewmembercanaccomplishinthesharedworkspace;forexample,"Contributor".Aninvalidrolenameraisesanerror.
AddmethodasitappliestotheSharedWorkspaceTasksobject.
Addsatasktothelistoftasksinasharedworkspace.ReturnsaSharedWorkspaceTaskobject.
expression.Add(Title,Status,Priority,Assignee,Description,DueDate)
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceTasksobject.
Page 234
TitleRequiredString.Thetitleofthenewtask.
StatusOptionalmsoSharedWorkspaceTaskStatus.Thestatusofthenewtask.DefaultismsoSharedWorkspaceTaskStatusNotStarted.
MsoSharedWorkspaceTaskStatuscanbeoneofthesemsoSharedWorkspaceTaskStatusconstants.msoSharedWorkspaceTaskStatusCompletemsoSharedWorkspaceTaskStatusDeferredmsoSharedWorkspaceTaskStatusInProgressmsoSharedWorkspaceTaskStatusNotStartedmsoSharedWorkspaceTaskStatusWaiting
PriorityOptionalmsoSharedWorkspaceTaskPriority.Thepriorityofthenewtask.DefaultismsoSharedWorkspaceTaskPriorityNormal.
MsoSharedWorkspaceTaskPrioritycanbeoneoftheseMsoSharedWorkspaceTaskPriorityconstants.msoSharedWorkspaceTaskPriorityHighMsoSharedWorkspaceTaskPriorityLowMsoSharedWorkspaceTaskPriorityNormal
AssigneeOptionalSharedWorkspaceMember.Themembertowhomthenewtaskisassigned.
DescriptionOptionalString.Thedescriptionofthenewtask.
DueDateOptionalDate.Theduedateofthenewtask.
Page 235
Remarks
TheschemathatdefinessharedworkspacetasksandtheirpropertiesforaSharePointProductsandTechnologiessitecanbemodifiedontheserverinsuchawaythattheAddmethodoftheSharedWorkspaceTaskscollectionmayraiseanerror,ormaydisregardthevaluesofcertainarguments.Inparticular,thetaskstatusandpriorityenumerationscanbecustomized.Someexamplesoftheproblemsthatcanresultarementionedbelow:
IfaStatusargumentissupplied,andthestatusfieldhasbeenremovedfromthecustomizedtasksschema,theargumentwillbeignoredandnoerrorwillberaised.IfaStatusvalueissuppliedthatliesoutsidethestatusvaluesrecognizedbythecustomizedtasksschema,theargumentwillbeignored,thedefaultvaluewillbeused,andnoerrorwillberaised.Ifanewrequiredfieldhasbeenaddedtothecustomizedtasksschema,thentheAddmethodwillfailwithanerro,anditwillnolongerbepossibletousetheAddmethodtoaddnewtasks.
Page 236
Example
AsitappliestotheAnswerWizardFilesobject.
ThisexamplepreparestheAnswerWizardtoacceptacustomfilelistandaddstwocustomAnswerWizardfiles.First,theexampleclearsthefilelist,andthenitaddstwocustomAnswerWizardfilesandchecksthefilecountandthefilenamestoensurethatthefileswereaddedcorrectly.
DimcustomAnswerWizardAsAnswerWizard
SetcustomAnswerWizard=Application.AnswerWizard
customAnswerWizard.ClearFileList
customAnswerWizard.Files.Add("c:\awfiles\custom_1.aw")
customAnswerWizard.Files.Add("c:\awfiles\custom_2.aw")
IfcustomAnswerWizard.Files.Count=2Then
MsgBox"Files"&customAnswerWizard.Files.Item(1)&_
"and"&customAnswerWizard.Files(2)&_
"wereaddedsucessfully."
EndIf
AsitappliestotheCommandBarControlsobject.
Thisexamplecreatesacustomeditingtoolbarthatcontainsbuttons(controls)forcutting,copying,andpasting.
DimcustomBarAsCommandBar
DimnewButtonAsCommandBarButton
SetcustomBar=CommandBars.Add("Custom")
SetnewButton=customBar.Controls_
.Add(msoControlButton,CommandBars("Edit")_
.Controls("Cut").Id)
SetnewButton=customBar.Controls_
.Add(msoControlButton,CommandBars("Edit")_
.Controls("Copy").Id)
SetnewButton=customBar.Controls_
.Add(msoControlButton,CommandBars("Edit")_
.Controls("Paste").Id)
customBar.Visible=True
Page 237
AsitappliestotheDocumentPropertiesobject.
Thisexample,whichisdesignedtoruninMicrosoftWord,addsthreecustomdocumentpropertiestotheDocumentPropertiescollection.
WithActiveDocument.CustomDocumentProperties
.AddName:="CustomNumber",_
LinkToContent:=False,_
Type:=msoPropertyTypeNumber,_
Value:=1000
.AddName:="CustomString",_
LinkToContent:=False,_
Type:=msoPropertyTypeString,_
Value:="Thisisacustomproperty."
.AddName:="CustomDate",_
LinkToContent:=False,_
Type:=msoPropertyTypeDate,_
Value:=Date
EndWith
AsitappliestothePermissionobject.
Thefollowingexampleassignsacombinationofreadandeditpermissionsonthecurrentdocumenttoauserandspecifiesanexpirationdateforthesedocumentpermissions.
DimobjUserPermAsOffice.UserPermission
SetobjUserPerm=ActiveWorkbook.Permission.Add(_
"[email protected] ",_
msoPermissionRead+msoPermissionEdit,#12/31/2005#)
MsgBox"Permissionsaddedfor"&_
objUserPerm.UserId,_
vbInformation+vbOKOnly,_
"PermissionsAdded"
SetobjUserPerm=Nothing
AsitappliestothePropertyTestsobject.
Thisexampleaddstwopropertyteststothesearchcriteria.ThefirsttestisthatthefilesmustbeMicrosoftWorddocuments,andthesecondtestisthattheymusthavebeenmodifiedbetweenJanuary1,1996,andJune30,1996.Theexamplealsodisplaysamessageboxthatshowsthetotalnumberoffilesfound,ifany,andthenameofeachfilefound.
Page 238
Setfs=Application.FileSearch
fs.NewSearch
Withfs.PropertyTests
.AddName:="FilesofType",_
Condition:=msoConditionFileTypeWordDocuments,_
Connector:=msoConnectorOr
.AddName:="LastModified",_
Condition:=msoConditionAnytimeBetween,_
Value:="1/1/98",SecondValue:="6/30/98",_
Connector:=msoConnectorAnd
EndWith
Iffs.Execute()>0Then
Fori=1Tofs.FoundFiles.Count
strFound=strFound&fs.FoundFiles(i)&vbCrLf
Nexti
MsgBox"Searchfoundthefollowing"_
&fs.FoundFiles.Count&_
"file(s):"&vbCrLf&strFound
Else
MsgBox"Therewerenofilesfound."
EndIf
AsitappliestotheScriptsobject.
ThisexampleaddsanewScripttothespecifiedrangeonworksheetoneintheactiveworkbook.
DimrngScriptAnchorRangeAsRange
DimobjNewScriptAsScript
SetrngScriptAnchorRange=ActiveWorkbook._
Worksheets(1).Range("B5")
SetobjNewScript=ActiveWorkbook._
Worksheets(1).Scripts.Add(rngScriptAnchorRange,_
msoScriptLocationInBody,_
msoScriptLanguageVisualBasic,_
"MyNewScript",,_
"MsgBox(""AddedScriptobjectMyNewScript"")")
AsitappliestotheSharedWorkspaceFilesobject.
Thefollowingexampleaddsanewfiletothefilescollectionofthesharedworkspace.
DimswsfileAsOffice.SharedWorkspaceFile
Page 239
Setswsfile=ActiveWorkbook.SharedWorkspace.Files.Add(_
"C:\MyWorkbook.xls",_
,True,True)
MsgBox"NewfileURL:"&swsfile.URL,_
vbInformation+vbOKOnly,_
"NewFileinSharedWorkspaceFiles"
Setswsfile=Nothing
AsitappliestotheSharedWorkspaceFoldersobject.
Thefollowingexampleaddsanewfoldertothefolderscollectionofthesharedworkspace.
DimswsFolderAsOffice.SharedWorkspaceFolder
SetswsFolder=ActiveWorkbook.SharedWorkspace.Folders.Add("MyNewFolder")
MsgBox"Newfolder:"&swsFolder.FolderName,_
vbInformation+vbOKOnly,_
"NewFolderinSharedWorkspace"
SetswsFolder=Nothing
AsitappliestotheSharedWorkspaceLinksobject.
Thefollowingexampleaddsanewlinktothelinkscollectionofthesharedworkspace.
DimswsLinkAsOffice.SharedWorkspaceLink
SetswsLink=ActiveWorkbook.SharedWorkspace.Links.Add(_
"http://msdn.microsoft.com",_
"MicrosoftDeveloperNetworkHomePage",_
"Myfavoritedevelopersite!")
MsgBox"Newlink:"&swsLink.Description,_
vbInformation+vbOKOnly,_
"NewLinkinSharedWorkspace"
SetswsLink=Nothing
AsitappliestotheSharedWorkspaceMembersobject.
Thefollowingexampleaddsanewmembertothememberscollectionofthesharedworkspaceintheroleofasitecontributor.
DimswsMemberAsOffice.SharedWorkspaceMember
SetswsMember=ActiveWorkbook.SharedWorkspace.Members.Add(_
"[email protected] ",_
"domain\user",_
"NewUser",_
Page 240
"Contributor")
MsgBox"Newmember:"&swsMember.Name,_
vbInformation+vbOKOnly,_
"NewMemberinSharedWorkspace)"
SetswsMember=Nothing
AsitappliestotheSharedWorkspaceTasksobject.
Thefollowingexampleaddsanewtasktothetaskscollectionofthesharedworkspace,specifiesaduedate,andassignsthetasktothefirstmemberofthesharedworkspace.
DimswsTaskAsOffice.SharedWorkspaceTask
DimswsMemberAsOffice.SharedWorkspaceMember
SetswsMember=ActiveWorkbook.SharedWorkspace.Members(1)
SetswsTask=ActiveWorkbook.SharedWorkspace.Tasks.Add(_
"Completedocumentbyyear-end",_
msoSharedWorkspaceTaskStatusNotStarted,_
msoSharedWorkspaceTaskPriorityNormal,_
swsMember,_
"Myfirstsharedworkspacetask",#12/31/2005#)
MsgBox"Newtask:"&swsTask.Title,_
vbInformation+vbOKOnly,_
"NewTaskinSharedWorkspace"
SetswsMember=Nothing
SetswsTask=Nothing
Page 242
AddItemMethodAddsalistitemtothespecifiedcommandbarcomboboxcontrol.Thecomboboxcontrolmustbeacustomcontrolandmustbeadrop-downlistboxoracombobox.
NoteThismethodwillfailifit'sappliedtoaneditboxorabuilt-incomboboxcontrol.
expression.AddItem(Text,Index)
expressionRequired.AnexpressionthatreturnsaCommandBarComboBoxobject.
TextRequiredString.Thetextaddedtothecontrol.
IndexOptionalVariant.Thepositionoftheiteminthelist.Ifthisargumentisomitted,theitemisaddedtotheendofthelist.
Page 243
Example
Thisexampleaddsacomboboxcontroltoacommandbar.Twoitemsareaddedtothecontrol,andthenumberoflineitemsandthewidthofthecomboboxareset.
SetmyBar=CommandBars("Custom")
SetmyControl=myBar.Controls.Add(Type:=msoControlComboBox,Id:=1)
WithmyControl
.AddItem"FirstItem",1
.AddItem"SecondItem",2
.DropDownLines=3
.DropDownWidth=75
.ListHeaderCount=0
EndWith
Page 244
AddToSearchFoldersMethodAddsaScopeFolderobjecttheSearchFolderscollection.
expression.AddToSearchFolders
expressionRequired.AnexpressionthatreturnsaScopeFolderobject.
Page 245
Remarks
AlthoughyoucanusetheSearchFolderscollection'sAddmethodtoaddaScopeFolderobjecttotheSearchFolderscollection,itisusuallysimplertousetheAddToSearchFoldersmethodoftheScopeFolderobjectthatyouwanttoadd,becausethereisonlyoneSearchFolderscollectionforallsearches.
Page 246
Example
ThefollowingexampleaddstherootScopeFolderobjecttotheSearchFolderscollection.ForalongerexamplethatusestheAddToSearchFoldersmethod,seetheSearchFolderscollectiontopic.
Application.FileSearch.SearchScopes(1).ScopeFolder.AddToSearchFolders
Page 247
ApplyFilterMethodAppliesafiltertoamailmergedatasourcetofilterspecifiedrecordsmeetingspecifiedcriteria.
expression.ApplyFilter
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 248
Example
ThisexampleaddsanewfilterthatremovesallrecordswithablankRegionfieldandthenappliesthefiltertotheactivepublication.
SubOfficeFilters()
DimappOfficeAsOfficeDataSourceObject
DimappFiltersAsODSOFilters
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
SetappFilters=appOffice.Filters
MsgBoxappOffice.RowCount
appFilters.AddColumn:="Region",Comparison:=msoFilterComparisonEqual,_
Conjunction:=msoFilterConjunctionAnd,bstrCompareTo:="WA"
appOffice.ApplyFilter
MsgBoxappOffice.RowCount
EndSub
Page 249
ApplyPolicyMethodAppliesthespecifiedpermissionpolicytotheactivedocument.
expression.ApplyPolicy(Filename)
expressionRequired.AnexpressionthatreturnsaPermissionobject.
FilenameRequiredString.Thepathandfilenameofthepermissionpolicytemplatefile.
Page 250
Remarks
MicrosoftOfficeInformationRightsManagementsupportstheuseofadministrativepermissionpolicieswhichlistusersandgroupsandtheirdocumentpermissions.TheApplyPolicymethodappliesapermissionpolicytotheactivedocument.
Page 251
Example
Thefollowingexampleenablespermissionsontheactivedocumentandappliesanadministrativepermissionpolicy.
DimirmPermissionAsOffice.Permission
SetirmPermission=ActiveWorkbook.Permission
DimstrIRMInfoAsString
SelectCaseirmPermission.Enabled
CaseTrue
strIRMInfo="Permissionsarealreadyrestrictedonthisdocument."
CaseFalse
WithirmPermission
.Enabled=True
.ApplyPolicy("\\server\share\permissionpolicy.xml")
EndWith
strIRMInfo="Permissionsarenowrestrictedonthisdocument"&_
vbCrLf&_
"andthepermissionpolicyhasbeenapplied."
EndSelect
MsgBoxstrIRMInfo,vbInformation+vbOKOnly,"IRMInformation"
SetirmPermission=Nothing
Page 253
ClearMethodRemovesalllistitemsfromacommandbarcomboboxcontrol(drop-downlistboxorcombobox)andclearsthetextbox(editboxorcombobox).
NoteThismethodwillfailifit'sappliedtoabuilt-incommandbarcontrol.
expression.Clear
expressionRequired.AnexpressionthatreturnsaCommandBarComboBoxobject.
Page 254
Example
Thisexamplechecksthenumberofitemsinthecomboboxcontrolonthecommandbarnamed"Custom."Iftherearefewerthanthreeitemsinthelistinthecombobox,theexampleclearsthelist,addsanewfirstitemtothelist,andthendisplaysthisnewitemasthedefaultforthecomboboxcontrol.
SetmyBar=CommandBars("CustomBar")
SetmyControl=myBar.Controls_
Type:=msoControlComboBox)
WithmyControl
.AddItem"FirstItem",1
.AddItem"SecondItem",2
EndWith
IfmyControl.ListCount<3Then
myControl.Clear
myControl.AddItemText:="NewItem",Index:=1
EndIf
Page 255
ClearFileListMethodClearsthelistoffilesforthecurrentAnswerWizard,includingthedefaultlistoffilesfortheMicrosoftOfficehostapplication.
expression.ClearFileList
expressionAnexpressionthatreturnsanAnswerWizardobject.
Page 256
Remarks
Usethismethodtoremoveallentriesfromthecurrentfilelistforthespecifiedapplication.YoucanalsouseittoensurethatnoneofthedefaultAnswerWizardfilesforthehostapplicationareavailabletousers.YoucanthenbuildacustomlistoffilesbyusingtheAddmethodoftheAnswerWizardFilescollection.
TorestorethedefaultAnswerWizardfilesetforthehostapplication,usetheResetFileListmethod.
Page 257
Example
ThisexamplepreparestheAnswerWizardtoacceptacustomfilelistandthenaddstwocustomAnswerWizardfiles.First,theexampleclearsthefilelist,andthenitaddstwocustomAnswerWizardfilesandchecksthefilecountandthefilenamestoensurethatthefileswereaddedcorrectly.
DimcustomAnswerWizardAsAnswerWizard
SetcustomAnswerWizard=Application.AnswerWizard
customAnswerWizard.ClearFileList
customAnswerWizard.Files.Add("c:\awfiles\custom_1.aw")
customAnswerWizard.Files.Add("c:\awfiles\custom_2.aw")
IfcustomAnswerWizard.Files.Count=2Then
MsgBox"Files"&customAnswerWizard.Files.Item(1)&_
"and"&customAnswerWizard.Files(2)&_
"wereaddedsucessfully."
EndIf
Page 258
CloseMethodClosestheactivemodelessballoon.Youshouldusethismethodonlyincallbackprocedures.
expression.Close
expressionRequired.AnexpressionthatreturnsaBalloonobject.
Page 259
Example
Thisexampledisplaysaballoonthatcontainsabuttonforeachofthreeprinters.Whenevertheuserclicksoneofthesebuttons,theProcessPrintercallbackprocedureisrunandtheballoonisclosed.
SubselectPrinter()
Setbln=Assistant.NewBalloon
Withbln
.Heading="SelectaPrinter."
.Labels(1).Text="NetworkPrinter"
.Labels(2).Text="LocalPrinter"
.Labels(3).Text="LocalColorPrinter"
.BalloonType=msoBalloonTypeButtons
.Mode=msoModeModeless
.Callback="ProcessPrinter"
.Show
EndWith
EndSub
SubProcessPrinter(blnAsBalloon,lbtnAsLong,_
lPrivAsLong)
Assistant.Animation=msoAnimationPrinting
SelectCaselbtn
Case-1
'Insertnetworkprinter-specificcode.
Case-2
'Insertlocalprinter-specificcode.
Case-3
'Insertcolorprinter-specificcode.
EndSelect
bln.Close
EndSub
Page 260
CommitMethodCommitsallchangesofthespecifiedSignatureSetcollectiontodisk.UntiltheCommitmethodisexecuted,noneofthechangestotheSignatureSetcollectionaresaved.
expression.Commit
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 261
Example
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandcallthisfunction.Thefunctionwilltesttomakesurethatthedigitalsignaturethattheuserselectswillnotexpireinlessthan12months.Ifitwillexpire,thecertificateisn'tattached.
FunctionAddSignature()AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
'TesttomakesurethatthenewSignatureobject
'doesn'texpiretoosoon.Thisexpressioncalculates
'thenumberofmonthsuntiltheSignatureobjectexpires.
IfDateDiff("m",sig.SignDate,sig.ExpireDate)<12Then
MsgBox"Thiscertificatewillexpireinlessthan1year."&vbCrLf&_
"Pleaseuseanewercertificate."
AddSignature=False
sig.Delete
Else
AddSignature=True
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 264
CopyMethodCopiesacommandbarcontroltoanexistingcommandbar.
expression.Copy(Bar,Before)
expressionRequired.AnexpressionthatreturnsaCommandBarControl,CommandBarButton,CommandBarPopup,orCommandBarComboBoxobject.
BarOptionalVariant.ACommandBarobjectthatrepresentsthedestinationcommandbar.Ifthisargumentisomitted,thecontroliscopiedtothecommandbarwherethecontrolalreadyexists.
BeforeOptionalVariant.Anumberthatindicatesthepositionforthenewcontrolonthecommandbar.Thenewcontrolwillbeinsertedbeforethecontrolatthisposition.Ifthisargumentisomitted,thecontroliscopiedtotheendofthecommandbar.
Page 265
Example
Thisexamplecopiesthefirstcontrolfromthecommandbarnamed"Standard"tothefirstcontrolonthecommandbarnamed"Custom”.
SetmyCustomBar=CommandBars("Custom")
SetmyControl=CommandBars("Standard").Controls(1)
WithmyControl
.CopyBar:=myCustomBar,Before:=1
.SetFocus
EndWith
Page 267
CopyFaceMethodCopiesthefaceofacommandbarbuttoncontroltotheClipboard.
expression.CopyFace
expressionRequired.AnexpressionthatreturnsaCommandBarButtonobject.
Page 268
Remarks
UsethePasteFacemethodtopastethecontentsoftheClipboardontoabuttonface.
Page 269
Example
Thisexamplefindsthebuilt-inOpenbutton,copiesthebuttonfacetotheClipboard,andthenpastesthefaceontotheSpellingandGrammarbutton.
SetmyControl=CommandBars.FindControl(Type:=msoControlButton,Id:=23)
myControl.CopyFace
SetmyControl=CommandBars.FindControl(Type:=msoControlButton,ID:=2)
myControl.PasteFace
Page 270
CreateNewMethodCreatesanewdocumentworkspaceontheserverandaddstheactivedocumenttothenewsharedworkspace.
expression.CreateNew(URL,Name)
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
URLOptionalString.TheURLfortheparentfolderinwhichthenewsharedworkspaceistobecreated.IfyoudonotsupplyaURL,thenewsharedworkspaceiscreatedintheuser'sdefaultserverlocation.
NameOptionalString.Thenameofthenewsharedworkspace.Defaultstothenameoftheactivedocumentwithoutitsfileextension.Forexample,ifyoucreateasharedworkspacefor"Budget.xls",thenameofthenewsharedworkspacebecomes"Budget".
Page 271
Remarks
UsetheCreateNewmethodtocreateanewsharedworkspacefortheactivedocument.Omitthe2optionalargumentstocreatetheworkspaceusingthenameoftheactivedocumentintheuser'sdefaultserverlocation.
TheCreateNewmethodraisesanerroriftheactivedocumenthaschangesthathavenotbeensaved.Thedocumentmustbesavedbeforeitcanbeaddedtoasharedworkspace.
Page 272
Example
ThefollowingexamplecreatesanewsharedworkspaceattheURLhttp://server/sites/mysite/,namestheworkspace"MySharedBudgetDocument",andaddstheactivedocumenttotheworkspace.TheURLpropertyofthenewsharedworkspacereturnshttp://server/sites/mysite/My%20Shared%20Budget%20Document/,theNamepropertyreturns"MySharedBudgetDocument,andCountpropertyoftheFilescollectionshowsasinglefile.
DimswsAsOffice.SharedWorkspace
DimstrSWSInfoAsString
Setsws=ActiveWorkbook.SharedWorkspace
sws.CreateNew"http://server/sites/mysite/","MySharedBudgetDocument"
strSWSInfo="Name:"&sws.Name&vbCrLf&_
"URL:"&sws.URL&vbCrLf&_
"File(s):"&sws.Files.Count
MsgBoxstrSWSInfo,vbInformation+vbOKOnly,_
"NewSharedWorkspaceInformation"
Setsws=Nothing
Page 274
DeleteMethodDeletemethodasitappliestotheAnswerWizardFilesobject.
Deletesthespecifiedobjectfromitscollection.
expression.Delete(FileName)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
FileNameRequiredString.Thenameofthefiletobedeleted,includingthefully-qualifiedpath,filename,andextension.
DeletemethodasitappliestotheCommandBar,Script,Scripts,andSignatureobjects.
Deletesthespecifiedobjectfromthecollection.
expression.Delete
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 275
Remarks
FortheScriptscollection,usingtheDeletemethodremovesallscriptsfromthespecifiedMicrosoftWorddocument,MicrosoftExcelworksheet,orMicrosoftPowerPointslide.Ascriptanchorisrepresentedbyashapeinthehostapplication.Therefore,theShapeobjectassociatedwitheachscriptanchoroftypemsoScriptAnchorisdeletedfromtheShapescollectioninExcelandPowerPointandfromtheInlineShapesandShapescollectionsinWord.
DeletemethodasitappliestotheCommandBarButton,CommandBarComboBox,CommandBarControl,andCommandBarPopupobjects.
Deletesthespecifiedobjectfromitscollection.
expression.Delete(Temporary)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
TemporaryOptionalVariant.Truetodeletethecontrolforthecurrentsession.Theapplicationwilldisplaythecontrolagaininthenextsession.
DeletemethodasitappliestotheDocumentLibraryVersionobject.
RemovesadocumentlibraryversionfromtheDocumentLibraryVersionscollection.
expression.Delete
expressionRequired.AnexpressionthatreturnsaDocumentLibraryVersionobject.
DeletemethodasitappliestotheDocumentPropertyobject.
Removesacustomdocumentproperty.
expression.Delete
Page 276
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 277
Remarks
Youcannotdeleteabuilt-indocumentproperty.
DeletemethodasitappliestotheFileDialogFiltersobject.
Removesafiledialogfilter.
expression.Delete(filter)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
filterOptionalVariant.Thefiltertoberemoved.
DeletemethodasitappliestotheODSOFiltersobject.
DeletesafilterobjectfromtheODSOFilterscollection.
expression.Delete(Index,DeferUpdate)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
IndexRequiredLong.Thenumberofthefiltertodelete.
DeferUpdateOptionalBoolean.
DeletemethodasitappliestotheSharedWorkspaceobject.
Deletesthecurrentsharedworkspaceandalldatawithinit.
expression.Delete
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
TheDeletemethodwillfailiftheuserdoesnothavepermissiontodeletethecurrentsharedworkspace.
Iftheactivedocumentwasopeneddirectlyfromtheworkspace,thenafter
Page 278
deletingtheworkspace,thedocumentwillnolongerbesavedondisk.Thedevelopermustremembertosavethedocumenttoanewlocationbeforeclosingit,orthedocumentwillceasetoexist.
DeletemethodasitappliestotheSharedWorkspaceFile,SharedWorkspaceLink,SharedWorkspaceMember,andSharedWorkspaceTaskobjects.
Deletesthecurrentobject.
expression.Delete
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
TheDeletemethodwillfailiftheuserdoesnothavepermissiontodeletethecurrentobjectfromthesharedworkspace.
DeletemethodasitappliestotheSharedWorkspaceFolderobject.
Deletesthecurrentsharedworkspacefolderandalldatawithinit.
expression.Delete(DeleteEvenIfFolderContainsFiles)
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceFolderobject.
DeleteEvenIfFolderContainsFilesOptionalBoolean.Truetodeletethefolderwithoutwarningevenifthefoldercontainsfiles.DefaultisFalse.
TheDeletemethodwillfailiftheuserdoesnothavepermissiontodeletethecurrentfolderfromthesharedworkspace.
Page 279
Example
AsitappliestotheCommandBarobject.
Thisexampledeletesallcustomcommandbarsthataren'tvisible.
foundFlag=False
delBars=0
ForEachbarInCommandBars
If(bar.BuiltIn=False)And_
(bar.Visible=False)Then
bar.Delete
foundFlag=True
delBars=delBars+1
EndIf
Nextbar
IfNotfoundFlagThen
MsgBox"Nocommandbarshavebeendeleted."
Else
MsgBoxdelBars&"custombar(s)deleted."
EndIf
AsitappliestotheDocumentPropertyobject.
Thisexampledeletesacustomdocumentproperty.Forthisexampletorunproperly,youmusthaveacustomDocumentPropertyobjectnamed"CustomNumber".
ActiveDocument.CustomDocumentProperties("CustomNumber").Delete
Page 280
DisconnectMethodDisconnectsthelocalcopyoftheactivedocumentfromthesharedworkspace.
expression.Disconnect()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 281
Remarks
UsetheDisconnectmethodtodetachthelocalcopyoftheactivedocumentfromthesharedworkspace.Thismethodleavestheshareddocumentontheserver;however,thelocalcopywillnolongerbesynchronizedwiththesharedcopyandwillnolongerbenefitfromtheothercollaborationfeaturesofthesharedworkspace.UsetheRemoveDocumentmethodtoremovetheshareddocumentfromtheserver.
Page 282
Example
Thefollowingexampledetermineswhethertheactivedocumentisconnectedtoasharedworkspace,thenofferstheusertheoptionofdisconnectingit.
DimrAsLong
IfActiveWorkbook.SharedWorkspace.ConnectedThen
r=MsgBox("Areyousureyouwanttodisconnectthisdocument?",_
vbQuestion+vbOKCancel,"Areyousure?")
Ifr=vbOKThen
ActiveWorkbook.SharedWorkspace.Disconnect
MsgBox"Thedocumenthasbeendisconnected.",_
vbInformation+vbOKOnly,"Disconnected"
Else
MsgBox"Disconnectcancelled.",_
vbInformation+vbOKOnly,"StillConnected"
EndIf
Else
MsgBox"Theactivedocumentisnotconnectedtoasharedworkspace.",_
vbInformation+vbOKOnly,"NotConnected"
EndIf
Page 284
DoAlertMethodDisplaysanalertandreturnsaLongthatindicateswhichbuttontheuserpressed.YoucanchoosetodisplaythisalerteitherthroughtheMicrosoftOfficeAssistantorasanormalmessagebox.
expression.DoAlert(bstrAlertTitle,bstrAlertText,alb,alc,ald,alq,varfSysAlert)
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
bstrAlertTitleRequiredString.Setsthetitleofthealert.
bstrAlertTextRequiredString.Setsthetextofthealert.
albRequiredMsoAlertButtonType.Determineswhichbuttonsaredisplayedonthealert.
MsoAlertButtonTypecanbeoneoftheseMsoAlertButtonTypeconstants.msoAlertButtonAbortRetryIgnoremsoAlertButtonOKmsoAlertButtonOKCancelmsoAlertButtonRetryCancelmsoAlertButtonYesAllNoCancelOnlyusethiswhenthevarfSysAlertargumentissettoFalse.msoAlertButtonYesNomsoAlertButtonYesNoCancel
alcRequiredMsoAlertIconType.Determinestheiconthatisdisplayedonthealert.
MsoAlertIconTypecanbeoneoftheseMsoAlertIconTypeconstants.msoAlertIconCriticalmsoAlertIconInfo
Page 285
msoAlertIconNoIconmsoAlertIconQuerymsoAlertIconWarning
aldRequiredMsoAlertDefaultType.Determineswhichbuttonissetasthedefaultbuttonofthealert.Ifthisargumentissettoavaluegreaterthanthenumberofbuttons,anerrorisreturned.
MsoAlertDefaultTypecanbeoneoftheseMsoAlertDefaultTypeconstants.msoAlertDefaultFifthmsoAlertDefaultFirstmsoAlertDefaultFourthmsoAlertDefaultSecondmsoAlertDefaultThird
alqRequiredMsoAlertCancelType.AlwayssetthistomsoAlertCancelDefault.Anyothersettingmayreturnanerror.
MsoAlertCancelTypecanbeoneoftheseMsoAlertCancelTypeconstants.msoAlertCancelDefaultmsoAlertCancelFifthmsoAlertCancelFirstmsoAlertCancelFourthmsoAlertCancelSecondmsoAlertCancelThird
varfSysAlertRequiredBoolean.TrueifthealertisdisplayedinamessageboxorFalseifthealertisdisplayedthroughtheOfficeAssistant.
Page 286
Remarks
ThereturnvaluesoftheDoAlertmethodcorrespondstothevaluesofthevbMsgBoxResultenumeratedtype(forexample,vbYes,vbNo,orvbCancel).Inadditiontothesevalues,thefollowingvaluesmayalsobereturned:
"Yestoall"=8"Tryagain"=10"Continue"=11
Page 287
Example
ThefollowingexampledisplaysanalertthroughtheOfficeAssistantanddisplaysamessageboxindicatingwhichbuttontheuserpressed.Iftheassistantisdisabled,thealertisdisplayedinanormalmessagebox.
SubAssistantAlert()
WithApplication.Assistant
SelectCase_
.DoAlert(_
"Test",_
"Clickabutton.",_
msoAlertButtonYesAllNoCancel,_
msoAlertIconCritical,_
msoAlertDefaultSecond,_
msoAlertCancelFirst,_
False)
CasevbYes:MsgBox"TheuserclickedYes."
CasevbNo:MsgBox"TheuserclickedNo."
CasevbCancel:MsgBox"TheuserclickedCancel."
Case8:MsgBox"TheuserclickedYesToAll"'ThisisthereturnvalueforYesToAll
CaseElse
EndSelect
EndWith
EndSub
Page 288
EndWizardMethodSomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ReleasesthevariablereturnedbytheStartWizardmethod.
NoteYoushouldusethismethodonlywiththeStartWizardmethod.
expression.EndWizard(WizardID,varfSuccess,Animation)
expressionRequired.AnexpressionthatreturnsanAssistantobject.
WizardIDRequiredLong.ThenumberreturnedbytheStartWizardmethod.
varfSuccessRequiredBoolean.Truetoindicatethattheusercompletedthewizardsuccessfully.
AnimationOptionalVariant.TheanimationtheOfficeAssistantperformsifvarfSuccessissettoTrue.ThedefaultvalueismsoAnimationCharacterSuccessMajor.
Page 289
Example
ThisexampleclosestheOfficeAssistantforawizardsessionthatwascompletedsuccessfullybytheuser.ThevariablelHelpForWizwasassignedthereturnvalueoftheStartWizardmethod.
Assistant.EndWizardWizardId:=lHelpForWiz,_
varfSuccess:=True,Animation:=msoAnimationGoodbye
Page 291
ExecuteMethodExecutemethodasitappliestotheFileSearchobject.
Beginsthesearchforthespecifiedfile(s).ReturnsaLong;zero(0)ifnofilesarefound,orapositivenumberifoneormorefilesarefound.
expression.Execute(SortBy,SortOrder,AlwaysAccurate)
expressionRequired.AnexpressionthatreturnsaFileSearchobject.
SortByOptionalMsoSortBy.Themethodusedtosortthereturnedfile(s).
MsoSortBycanbeoneoftheseMsoSortByconstants.msoSortByFileNamedefaultmsoSortByFileTypemsoSortByLastModifiedmsoSortByNonemsoSortBySize
SortOrderOptionalMsoSortOrder.Theorderinwhichthereturnedfile(s)aresorted.
MsoSortOrdercanbeoneoftheseMsoSortOrderconstants.msoSortOrderAscendingdefaultmsoSortOrderDescending
AlwaysAccurateOptionalBoolean.Truetohavethefilesearchincludefilesthathavebeenadded,modified,ordeletedsincethefileindexwaslastupdated.ThedefaultvalueisTrue.
ExecutemethodasitappliestotheCommandBarButton,CommandBarComboBox,CommandBarControl,CommandBarPopup,andFileDialogobjects.
Page 292
Forthecommandbarobjects,runstheprocedureorbuilt-incommandassignedtothespecifiedcommandbarcontrol.Forcustomcontrols,usetheOnActionpropertytospecifytheproceduretoberun.
ForFileDialogobjectsoftypemsoFileDialogOpenormsoFileDialogSaveAs,carriesoutauser'sactionrightaftertheShowmethodisinvoked.
expression.Execute
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 293
Example
AsitappliestotheFileSearchobject.
ThisexamplesearchesforallfilesintheMyDocumentsfolderthatendwiththefilenameextension“.doc”andthendisplaysthelocationandnameofeachfilefound.Theexamplealsosortsthelistofreturnedfilenamesinascendingalphabeticorder.
Setfs=Application.FileSearch
Withfs
.LookIn="C:\MyDocuments"
.FileName="*.doc"
If.Execute(SortBy:=msoSortbyFileName,_
SortOrder:=msoSortOrderAscending)>0Then
MsgBox"Therewere"&.FoundFiles.Count&_
"file(s)found."
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
Nexti
Else
MsgBox"Therewerenofilesfound."
EndIf
EndWith
AsitappliestotheCommandBarButton,CommandBarComboBox,CommandBarControl,andCommandBarPopupobjects.
ThisMicrosoftExcelexamplecreatesacommandbarandthenaddsabuilt-incommandbarbuttoncontroltoit.ThebuttonexecutestheExcelAutoSumfunction.ThisexampleusestheExecutemethodtototaltheselectedrangeofcellswhenthecommandbarappears.
DimcbrCustBarAsCommandBar
DimctlAutoSumAsCommandBarButton
SetcbrCustBar=CommandBars.Add("Custom")
SetctlAutoSum=cbrCustBar.Controls_
.Add(msoControlButton,CommandBars("Standard")_
.Controls("AutoSum").Id)
cbrCustBar.Visible=True
ctlAutoSum.Execute
Page 296
FindControlMethodReturnsaCommandBarControlobjectthatfitsaspecifiedcriteria.
expression.FindControl(Type,Id,Tag,Visible,Recursive)
expressionRequired.AnexpressionthatreturnsaCommandBarsobject.
TypeOptionalMsoControlType.Thetypeofcontrol.
MsoControlTypetypecanbeoneoftheseMsoControlTypeconstants.msoControlActiveXmsoControlAutoCompleteCombomsoControlButtonmsoControlButtonDropdownmsoControlButtonPopupmsoControlComboBoxmsoControlCustommsoControlDropdownmsoControlEditmsoControlExpandingGridmsoControlGaugemsoControlGenericDropdownmsoControlGraphicCombomsoControlGraphicDropdownmsoControlGraphicPopupmsoControlGridmsoControlLabelmsoControlLabelExmsoControlOCXDropDownmsoControlPanemsoControlPopupmsoControlSpinner
Page 297
msoControlSplitButtonMRUPopupmsoControlSplitButtonPopupmsoControlSplitDropdownmsoControlSplitExpandingGridmsoControlWorkPane
IdOptionalVariant.Theidentifierofthecontrol.
TagOptionalVariant.Thetagvalueofthecontrol.
VisibleOptionalVariant.Truetoincludeonlyvisiblecommandbarcontrolsinthesearch.ThedefaultvalueisFalse.VisiblecommandbarsincludeallvisibletoolbarsandanymenusthatareopenatthetimetheFindControlmethodisexecuted.
RecursiveOptionalBoolean.Truetoincludethecommandbarandallofitspop-upsubtoolbarsinthesearch.ThisargumentonlyappliestotheCommandBarobject.ThedefaultvalueisFalse.
Page 298
Remarks
IftheCommandBarscollectioncontainstwoormorecontrolsthatfitthesearchcriteria,FindControlreturnsthefirstcontrolthat'sfound.Ifnocontrolthatfitsthecriteriaisfound,FindControlreturnsNothing.
Page 299
Example
Thisexamplefindsthefirstcontrolonthecommandbarnamed“Custom”.Ifthecontrolisabutton,theexampleusestheFindControlmethodtofindtheCopybutton(ontheStandardtoolbar)andthencopiesthefacefromtheCopybuttonandpastesitontothecontrol.
SetoldCtrl=CommandBars("Custom").Controls(1)
IfoldCtrl.Type=1Then
SetnewCtrl=CommandBars.FindControl(Type:=_
MsoControlButton,ID:=_
CommandBars("Standard").Controls("Copy").ID)
NewCtrl.CopyFace
OldCtrl.PasteFace
EndIf
Page 301
FindControlsMethodReturnstheCommandBarControlscollectionthatfitsthespecifiedcriteria.
expression.FindControls(Type,Id,Tag,Visible)
expressionRequired.AnexpressionthatreturnsaCommandBarControlscollection.
TypeOptionalMsoControlType.Thetypeofcontrol.
MsoControlTypetypecanbeoneoftheseMsoControlTypeconstants.msoControlActiveXmsoControlAutoCompleteCombomsoControlButtonmsoControlButtonDropdownmsoControlButtonPopupmsoControlComboBoxmsoControlCustommsoControlDropdownmsoControlEditmsoControlExpandingGridmsoControlGaugemsoControlGenericDropdownmsoControlGraphicCombomsoControlGraphicDropdownmsoControlGraphicPopupmsoControlGridmsoControlLabelmsoControlLabelExmsoControlOCXDropDownmsoControlPanemsoControlPopup
Page 302
msoControlSpinnermsoControlSplitButtonMRUPopupmsoControlSplitButtonPopupmsoControlSplitDropdownmsoControlSplitExpandingGridmsoControlWorkPane
IdOptionalVariant.Thecontrol’sidentifier.
TagOptionalVariant.Thecontrol’stagvalue.
VisibleOptionalVariant.Truetoincludeonlyvisiblecommandbarcontrolsinthesearch.ThedefaultvalueisFalse.
Page 303
Remarks
Ifnocontrolsthatfitsthecriteriaarefound,theFindControlsmethodreturnsNothing.
Page 304
Example
ThisexampleusestheFindControlsmethodtoreturnallmembersoftheCommandBarscollectionthathaveanIDof18anddisplays(inamessagebox)thenumberofcontrolsthatmeetthesearchcriteria.
DimmyControlsAsCommandBarControls
SetmyControls=CommandBars.FindControls(Type:=msoControlButton,ID:=18)
MsgBox"Thereare"&myControls.Count&_
"controlsthatmeetthesearchcriteria."
Page 305
GetUpdateMethodComparesthelocalversionoftheshareddocumenttotheversionontheserver.
expression.GetUpdate
expressionRequired.AnexpressionthatreturnsaSyncobject.
Page 306
Remarks
UsetheGetUpdatemethodtocomparethelocalversionoftheshareddocumenttotheversionontheserverandtorefreshthesyncstatus.
Notalldocumentsynchronizationproblemsraisetrappablerun-timeerrors.AfterperforminganoperationusingtheSyncobject,it'sagoodideatochecktheStatusproperty;iftheStatuspropertyismsoSyncStatusError,checktheErrorTypepropertyforadditionalinformationonthetypeoferrorthathasoccurred.
Inmanycircumstances,thebestwaytoresolveanerrorconditionistocalltheGetUpdatemethod.Forexample,ifacalltoPutUpdateresultsinanerrorcondition,thenacalltoGetUpdatewillresetthestatustomsoSyncStatusLocalChanges.
Page 307
Example
ThefollowingexamplecomparesthelocalandservercopiesofthedocumentusingtheGetUpdatemethodandreportswhethertheserverhasanewercopy.
DimobjSyncAsOffice.Sync
DimstrStatusAsString
SetobjSync=ActiveDocument.Sync
objSync.GetUpdate
IfobjSync.Status=msoSyncStatusNewerAvailableThen
strStatus="Anewerversionisavailableontheserver."
MsgBoxstrStatus,vbInformation+vbOKOnly,"SyncInformation"
EndIf
SetobjSync=Nothing
Page 308
HelpMethodSomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
DisplaystheOfficeAssistantandthebuilt-in"Whatwouldyouliketodo?"AssistantballoonforstandardOfficeonlineHelp.
expression.Help
expressionRequired.AnexpressionthatreturnsanAssistantobject.
Page 309
Example
Thisexampledisplaysthebuilt-in"Whatwouldyouliketodo?"Assistantballoonwhentheuserchecksthe"Ineedmoreinformation"checkbox.
Setb=Assistant.NewBalloon
Withb
.Heading="UserInformation"
.Text="Selectyourskilllevel"
.CheckBoxes(1).Text="Beginner."
.CheckBoxes(2).Text="Advanced."
.CheckBoxes(3).Text="Ineedmoreinformation."
.Show
EndWith
Ifb.CheckBoxes(3).Checked=TrueThen
Assistant.Help
EndIf
Page 311
ItemMethodItemmethodasitappliestotheCOMAddInsobject.
ReturnsamemberofthespecifiedCOMAddInscollection.
expression.Item(Index)
expressionRequired.ThespecifiedCOMAddInscollection.
IndexRequiredVariant.EitheranordinalvaluethatreturnstheCOMadd-inatthatpositionintheCOMAddInscollection,oraStringvaluethatrepresentstheProgIDofthespecifiedCOMadd-in.
ItemmethodasitappliestotheFileDialogFiltersobject.
ReturnsaFileDialogFilterobjectthatisamemberofthespecifiedFileDialogFilterscollection.
expression.Item(Index)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
IndexRequiredLong.TheindexnumberoftheFileDialogFilterobjecttobereturned.
ItemmethodasitappliestotheFileDialogSelectedItemsobject.
ReturnsaStringthatcorrespondstothepathofoneofthefilesthattheuserselectedfromafiledialogboxthatwasdisplayedusingtheShowmethodoftheFileDialogobject.TheFileDialogSelectedItemscollectionisacollectionofstrings.
expression.Item(Index)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 312
IndexRequiredLong.Theindexnumberofthestringtobereturned.
ItemmethodasitappliestotheHTMLProjectItemsobject.
ReturnstheHTMLProjectItemobjectthatrepresentsaparticularprojectintheMicrosoftScriptEditor.
expression.Item(Index)
expressionRequired.AnHTMLProjectItemscollection.
IndexRequiredVariant.ThenameorindexnumberoftheHTMLprojectitemtobereturned.
ItemmethodasitappliestotheScriptsobject.
ReturnsamemberoftheScriptscollection.AcceptstheindexnumberorIDofthescriptyouwanttheMicrosoftOfficeapplicationtoreturn.TheItemmethodacceptsaVariantvaluethatcanaccepteitheranordinalnumber(indexvalue),whichreturnsthescriptstoredatthatpositionintheScriptscollection,oraStringvaluethatrepresentsthenameorIDofthescript.
expression.Item(Index)
expressionRequired.AnexpressionthatreturnsaScriptsobject.
IndexRequiredVariant.TheIDorindexnumberofthescripttobereturned.
Page 313
Remarks
TheScriptscollectioncontainsallofthescriptsinagivendocument,insourceorder(theorderinwhichScriptobjectsappearinthesourcefile).Scriptsaremaintainedinsourceorderregardlessoftheirlocationinthedocument—thatis,whetherthey’reintheheaderorthebodytext.
YoucanusetheItemmethodtoaccessascriptintheScriptscollectionbyusingtheIDofthe<SCRIPT>tag.TheIDattributeofthe<SCRIPT>tagisidenticaltotheIdpropertyoftheScriptobject.IfthereareduplicateormultipleIDsinthedocumentandyouusetheIdpropertyofaScriptobjecttoaccessascriptbyusingtheItemmethod,OfficereturnsthefirstscriptthatmatchestheID;additionalscriptswiththesameIDareignored.
NewscriptanchorsaddedtothecollectionareappendedtotheendoftheScriptscollectionintheorderinwhichtheywereaddedtothedocument.ThescriptanchorsremaininthisorderuntilthedocumentissavedasHTML,closed,andthenopenedagaininthehostapplication.FollowingthesestepscausestheScriptscollectiontobeindexedintheorderinwhichthescriptanchorsappearinthedocument,whichmaybedifferentthantheorderinwhichtheywereaddedtoit.Therefore,you’readvisedtousetheIdpropertyoftheScriptobject,ratherthanthescript’spositioninthecollection,toensurepositiveidentificationofthescript.
Page 314
LoadFromFileMethodUpdatesthetextintheMicrosoftScriptEditorwithtextfromthespecifiedfile(ondisk).
expression.LoadFromFile(Filename)
expressionAnHTMLProjectItemobject.
FilenameRequiredString.Thefullyqualifiedpathofthetextfilethatcontainsthetexttobeloaded.
Page 315
Example
ThisexampledetermineswhetherthespecifiedHTMLprojectitemisopen;iftheitemisopen,theexamplethenloadsscriptfromthespecifiedfile.
IfActiveWorkbook.HTMLProject.HTMLProjectItems_
.Item(1).IsOpenThen
ActiveWorkbook.HTMLProject.HTMLProjectItems_
.Item(1).LoadFromFile("C:\MyScript.txt")
Else
MsgBox"TheHTMLProjectItemisnotopen."
EndIf
Page 317
MoveMethodSomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
MovemethodasitappliestotheCommandBarButton,CommandBarComboBox,CommandBarControl,andCommandBarPopupobjects.
Movesthespecifiedcommandbarcontroltoanexistingcommandbar.
expression.Move(Bar,Before)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
BarOptionalVariant.ACommandBarobjectthatrepresentsthedestinationcommandbarforthecontrol.Ifthisargumentisomitted,thecontrolismovedtotheendofthecommandbarwherethecontrolcurrentlyresides.
BeforeOptionalVariant.Anumberthatindicatesthepositionforthecontrol.Thecontrolisinsertedbeforethecontrolcurrentlyoccupyingthisposition.Ifthisargumentisomitted,thecontrolisinsertedonthesamecommandbar.
MovemethodasitappliestotheAssistantobject.
MovestheOfficeAssistanttothespecifiedlocation.
expression.Move(xLeft,yTop)
expressionRequired.AnexpressionthatreturnsanAssistantobject.
xLeftRequiredInteger.TheleftpositionoftheOfficeAssistantwindow,inpoints.
yTopRequiredInteger.ThetoppositionoftheOfficeAssistantwindow,inpoints.
Page 318
Example
AsitappliestotheCommandBarButton,CommandBarComboBox,CommandBarControl,andCommandBarPopupobjects.
ThisexamplemovesthefirstcomboboxcontrolonthecommandbarnamedCustomtothepositionbeforetheseventhcontrolonthatcommandbar.Theexamplesetsthetagto"Selectionbox"andassignsthecontrolalowprioritysothatitwilllikelybedroppedfromthecommandbarifallthecontrolsdon'tfitinonerow.
Setallcontrols=CommandBars("Custom").Controls
ForEachctrlInallControls
Ifctrl.Type=msoControlComboBoxThen
Withctrl
.MoveBefore:=7
.Tag="Selectionbox"
.Priority=5
EndWith
ExitFor
EndIf
Next
AsitappliestotheAssistantobject.
ThisexampledisplaystheOfficeAssistantinthespecifiedlocationandsetsseveraloptionsbeforemakingitvisible.
WithAssistant
.Reduced=True
.MovexLeft:=400,yTop:=300
.MoveWhenInTheWay=True
.TipOfDay=True
.Visible=True
.Animation=msoAnimationGreeting
EndWith
Page 320
NewSearchMethodSomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
Resetsallthesearchcriteriasettingstotheirdefaultsettings.
expression.NewSearch
expressionRequired.AnexpressionthatreturnsaFileSearchobject.
Page 321
Remarks
Searchcriteriasettingsareretainedthroughoutanapplicationsession.Usethismethodeverytimeyouchangesearchcriteria.ThismethodwillnotresetthevalueoftheLookInproperty.
Page 322
Example
ThisexampleusestheNewSearchmethodtoresetthedefaultsearchcriteriabeforebeginninganewsearch.
WithApplication.FileSearch
.NewSearch
.LookIn="C:\MyDocuments"
.SearchSubFolders=True
.FileName="run"
.TextOrProperty="San*"
.MatchAllWordForms=True
.FileType=msoFileTypeAllFiles
If.Execute()>0Then
MsgBox"Therewere"&.FoundFiles.Count&_
"file(s)found."
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
Nexti
Else
MsgBox"Therewerenofilesfound."
EndIf
EndWith
Page 324
OpenMethodAsitappliestotheDocumentLibraryVersionobject.
OpensthespecifiedversionoftheshareddocumentfromtheDocumentLibraryVersionscollectioninread-onlymode.
expression.Open()
expressionRequired.AnexpressionthatreturnsaDocumentLibraryVersionobject.
AsitappliestotheHTMLProjectandHTMLProjectItemobjects.
OpensthespecifiedHTMLprojectorHTMLprojectitemintheMicrosoftScriptEditorinoneoftheviewsspecifiedbytheoptionalMsoHTMLProjectOpenconstantslistedbelow.Ifoneoftheconstantsisnotspecified,theprojectitemisopenedinthedefaultview.
expression.Open(OpenKind)
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
OpenKindOptionalMsoHTMLProjectOpen.Theviewinwhichthespecifiedprojectorprojectitemisopened.
MsoHTMLProjectOpencanbeoneoftheseMsoHTMLProjectOpenconstants.msoHTMLProjectOpenSourceViewmsoHTMLProjectOpenTextView
Page 325
Remarks
ThedefaultviewisdeterminedbywhetherornottheMicrosoftScriptEditorisopenwhentheOpenmethodisexecuted.IftheScriptEditorisnotopen,theOpenmethodstartstheScriptEditorinsourceview.IftheScriptEditorisalreadyopen,theOpenmethodactivatestheScriptEditoranddisplaysthescriptinthecurrentview.
Page 326
Example
AsitappliestotheDocumentLibraryVersionobject
Thefollowingexampleopenstheprevioussavedversionoftheactivedocumentinread-onlymode.
DimdlvVersionsAsOffice.DocumentLibraryVersions
SetdlvVersions=ActiveDocument.DocumentLibraryVersions
dlvVersions(dlvVersions.Count-1).Open
SetdlvVersions=Nothing
AsitappliestotheHTMLProjectobject
ThisexampleopenstheHTMLprojectintheactiveworkbookinsourceview.
AppActiveWorkbook.HTMLProject.Open_
(msoHTMLProjectOpenSourceView)
AsitappliestotheHTMLProjectItemobject
ThisexampleopensthefirstHTMLprojectitemintheactiveworkbookintextview.
ActiveWorkbook.HTMLProject.HTMLProjectItems_
Item(1).Open(msoHTMLProjectOpenTextView)
Page 328
OpenVersionMethodOpensadifferentversionoftheshareddocumentalongsidethecurrentlyopenlocalversion.
expression.OpenVersion(SyncVersionType)
expressionRequired.AnexpressionthatreturnsaSyncobject.
SyncVersionTypeRequiredMsoSyncVersionType.
MsoSyncVersionTypecanbeoneofthefollowingmsoSyncVersionTypeconstants.msoSyncVersionLastViewed(0)msoSyncVersionServer(1)
Page 329
Remarks
UsetheOpenVersionmethodtoopenthelastversionviewed(msoSyncVersionLastViewed)ortheservercopy(msoSyncVersionServer)oftheshareddocumentalongsidethecurrentlyopenlocalversion.
ThemsoSyncVersionLastViewedoptiondisplaysthecopyofthedocumentthatiscreatedwhenevertheuseroverwritesthelocalcopywiththeservercopy.Forexample,ifyoucalltheResolveConflictmethodwiththemsoSyncConflictServerWinsoption,thenyourlocalchangesaresavedandcanbeviewedbycallingOpenVersion(msoSyncVersionLastViewed).
Notalldocumentsynchronizationproblemsraisetrappablerun-timeerrors.AfterperforminganoperationusingtheSyncobject,it'sagoodideatochecktheStatusproperty;iftheStatuspropertyismsoSyncStatusError,checktheErrorTypepropertyforadditionalinformationonthetypeoferrorthathasoccurred.
Page 330
Example
Thefollowingexamplepromptstheusertoopentheservercopyoftheshareddocumentalongsidethecurrentlyopenlocalversion.
DimobjSyncAsOffice.Sync
DimlngChoiceAsVbMsgBoxResult
SetobjSync=ActiveDocument.Sync
lngChoice=MsgBox("Viewservercopy?",_
vbQuestion+vbOKCancel,"OpenServerVersion?")
IflngChoice=vbOKThen
objSync.OpenVersionmsoSyncVersionServer
EndIf
SetobjSync=Nothing
Page 332
PasteFaceMethodPastesthecontentsoftheClipboardontoacommandbarbuttoncontrol.
expression.PasteFace
expressionRequired.AnexpressionthatreturnsaCommandBarButtonobject.
Page 333
Example
Thisexamplefindsthebuilt-inFileOpenbuttonandpastesthefacefromtheSpellingandGrammarbuttonontoitfromtheClipboard.
SetmyControl=CommandBars.FindControl(Type:=msoControlButton,Id:=2)
myControl.CopyFace
SetmyControl=CommandBars.FindControl(Type:=msoControlButton,Id:=23)
myControl.PasteFace
Page 334
PickSolutionMethodDisplaysadialogboxwhichallowstheusertochooseanavailableXMLexpansionpacktoattachtotheactiveMicrosoftOfficeWord2003documentorMicrosoftOfficeExcel2003workbook.
expression.PickSolution(ConsiderAllSchemas)
expressionRequired.AnexpressionthatreturnsaSmartDocumentobject.
ConsiderAllSchemasOptionalBoolean.TruedisplaysallavailableXMLexpansionpacksinstalledontheuser'scomputer.FalsedisplaysonlyXMLexpansionpacksapplicabletotheactivedocument.DefaultvalueisFalse.
Page 335
Remarks
UsethePickSolutionmethodtoallowtheusertoselectanXMLexpansionpackfromalist.TheschemaattachedtotheactivedocumentorworkbookdetermineswhichXMLexpansionpacksareapplicable.
ThePickSolutionmethoddoesnotreturnavaluetoindicatewhethertheuserselectedanXMLexpansionpackorclickedCancelinthedialogbox.ChecktheSolutionIDpropertyaftercallingPickSolutiontodeterminewhetheranXMLexpansionpackhasbeenattached.
Ifthesmartdocumentdeveloperhasfailedtospecify"targetApplication"intheXMLexpansionpackmanifestfile,thelistdisplayedbyPickSolutionmayincludeXMLexpansionpacksthatarenottargetedtotheactiveapplication;forexample,anExcelusermayseeXMLexpansionpackstargetedexclusivelytoWord.Inthesecircumstances,theusermayselectanXMLexpansionpackthatisnotappropriatefortheactiveapplication.
FormoreinformationonsmartdocumentsorXMLexpansionpacksforsmartdocuments,pleaseseetheSmartDocumentSoftwareDevelopmentKit(SDK)ontheMicrosoftDeveloperNetwork(MSDN)Website.
Page 336
Example
ThefollowingexamplecheckstheSolutionIDpropertytodeterminewhethertheactiveMicrosoftWorddocumentalreadyhasanattachedXMLexpansionpack;ifnot,itdisplaysadialogboxwhichallowstheusertochooseanavailableXMLexpansionpack.Itthendisplaysthepropertiesofthesmartdocument.
DimobjSmartDocAsOffice.SmartDocument
DimstrSmartDocInfoAsString
SetobjSmartDoc=ActiveDocument.SmartDocument
IfobjSmartDoc.SolutionID="None"OrobjSmartDoc.SolutionID=""Then
objSmartDoc.PickSolutionTrue
EndIf
IfobjSmartDoc.SolutionID<>"None"AndobjSmartDoc.SolutionID<>""Then
strSmartDocInfo="SolutionID:"&objSmartDoc.SolutionID&vbCrLf&_
"SolutionURL:"&objSmartDoc.SolutionURL
MsgBoxstrSmartDocInfo,vbInformation+vbOKOnly,"SmartDocProperties"
Else
MsgBox"TheuserclickedCancel."
EndIf
SetobjSmartDoc=Nothing
Page 337
PutUpdateMethodUpdatestheservercopyoftheshareddocumentwiththelocalcopy.
expression.PutUpdate()
expressionRequired.AnexpressionthatreturnsaSyncobject.
Page 338
Remarks
ThePutUpdatemethodcanencounteraconflictconditioniftheclientisunawareofrecentchangestotheservercopyoftheshareddocument.CalltheGetUpdatemethodbeforecallingPutUpdatetorefreshthestatusoftheservercopyandtodetectapossibleconflict.
ThePutUpdatemethodraisesarun-timeerrorifthelocaldocumenthasunsavedchanges.
Notalldocumentsynchronizationproblemsraisetrappablerun-timeerrors.AfterperforminganoperationusingtheSyncobject,it'sagoodideatochecktheStatusproperty;iftheStatuspropertyismsoSyncStatusError,checktheErrorTypepropertyforadditionalinformationonthetypeoferrorthathasoccurred.
Inmanycircumstances,thebestwaytoresolveanerrorconditionistocalltheGetUpdatemethod.Forexample,ifacalltoPutUpdateresultsinanerrorcondition,thenacalltoGetUpdatewillresetthestatustomsoSyncStatusLocalChanges.
Page 339
Example
ThefollowingexampleupdatestheservercopyofthedocumentfromthelocalcopyusingthePutUpdatemethodifthelocalcopyhasbeenedited.
DimobjSyncAsOffice.Sync
DimstrStatusAsString
SetobjSync=ActiveDocument.Sync
IfobjSync.Status=msoSyncStatusLocalChangesThen
objSync.PutUpdate
strStatus="Localchangessavedtoserver."
MsgBoxstrStatus,vbInformation+vbOKOnly,"SyncInformation"
EndIf
SetobjSync=Nothing
Page 340
RefreshMethodRefreshesthelocalcacheoftheSharedWorkspaceobject'sfiles,folders,links,members,andtasksfromtheserver.
expression.Refresh()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 341
Remarks
UsetheRefreshmethodtoensurethatyouareworkingwiththemostup-to-datelistofobjectsandtheirpropertiesfromthesharedworkspace.
Page 342
Example
Thefollowingexamplerefreshesthesharedworkspaceifithasnotbeenrefreshedinthelast3minutes.Theexamplealsohandlestheerrorconditionwheretheworkspacehasnotyetbeenrefreshed.
OnErrorGoToerr_NeverRefreshed
IfDateDiff("s",ActiveWorkbook.SharedWorkspace.LastRefreshed,Now)>180Then
ActiveWorkbook.SharedWorkspace.Refresh
EndIf
ExitSub
err_NeverRefreshed:
ActiveWorkbook.SharedWorkspace.Refresh
Page 343
RefreshDocumentMethodRefreshesthespecifiedHTMLprojectintheMicrosoftOfficehostapplication.
expression.RefreshDocument(Refresh)
expressionAnexpressionthatreturnsanHTMLProjectobject.
RefreshRequiredBoolean.Trueifallchangesaretobesaved;Falseifallchangesaretobeignored.
Page 344
Remarks
UsingthismethodisequivalenttoclickingtheRefreshbuttonontheRefreshtoolbarintheOfficehostapplication.IfyourefreshthedocumentbysettingtheRefreshDocumentmethodtoTrue,allchangestotheHTMLsourcemadeintheMicrosoftScriptEditoraresavedintheOfficehostapplication.IfyousetRefreshDocumenttoFalse,allchangestotheHTMLsourceareignored.NotethatthevaluereturnedbytheStatemethodisaffectedbytheRefreshDocumentmethod.IfyoucallRefreshDocument(True),theStatemethodreturnsmsoHTMLProjectStateDocumentProjectUnlockedifitiscalledaftertherefreshoperation.
Page 345
Example
ThisexamplerefreshestheHTMLprojectintheactiveworkbookinthehostapplication.
ActiveWorkbook.HTMLProject.RefreshDocument(True)
Page 346
RefreshPaneMethodRefreshestheDocumentActionstaskpanefortheactiveMicrosoftOfficeWord2003documentorMicrosoftOfficeExcel2003workbook.
expression.RefreshPane()
expressionRequired.AnexpressionthatreturnsaSmartDocumentobject.
Page 347
Remarks
TheRefreshPanemethodraisesanerroriftheactivedocumentdoesnothaveanXMLexpansionpackattached.
Page 348
Example
ThefollowingexampledetermineswhethertheactiveMicrosoftExcelworkbookhasanXMLexpansionpackattached.Ifso,itrefreshesthesmartdocument'sDocumentActionstaskpane.
DimobjSmartDocAsOffice.SmartDocument
SetobjSmartDoc=ActiveWorkbook.SmartDocument
IfobjSmartDoc.SolutionID<>"None"Then
objSmartDoc.RefreshPane
Else
MsgBox"NoXMLexpansionpackattached."
EndIf
Page 349
RefreshProjectMethodRefreshesthespecifiedHTMLprojectintheMicrosoftScriptEditor.
expression.RefreshProject
expressionAnexpressionthatreturnsanHTMLProjectobject.
Page 350
Remarks
UsingthismethodisequivalenttoclickingtheRefreshbuttonontheRefreshtoolbarintheMicrosoftScriptEditor.IfyourefreshthedocumentbysettingRefreshDocumenttoTrue,allchangestotheHTMLsourcemadeintheOfficehostapplicationaresavedtotheHTMLprojectintheMicrosoftScriptEditor.IfyousetRefreshDocumenttoFalse,allchangestotheHTMLsourceareignored.
Page 351
Example
ThisexamplerefreshestheHTMLprojectintheMicrosoftScriptEditor.
ActiveWorkbook.HTMLProject.RefreshProject(True)
Page 352
RefreshScopesMethodRefreshesthelistofcurrentlyavailableScopeFolderobjects.
expression.RefreshScopes
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 353
Example
ThefollowingexampledisplaysallofthecurrentlyavailableScopeFolderobjectsontheC:\driveintheMyComputerscopeanddemonstratestheneedfortheRefreshScopesmethodwhenchangestothefolderlistoccur.
SubTestRefreshScopesMethod()
'DisplayswhathappensbeforeandaftertheRefreshScopes
'methodiscalledwhenanewfolderisaddedtothelist
'ofscopefolders.
'Listbeforethefolderiscreated.
CallListFolderNames
'CreateanewfolderontheC:\driveinMyComputer.
'Anerrorwilloccurifthisfolderalreadyexists.
MkDirPath:="C:\Delete_After_Using"
'Listafterthefolderiscreated.
'Thenewly-createdfolderdoesnotappearinthelist.
CallListFolderNames
'Refreshthelistoffolders.
Application.FileSearch.RefreshScopes
'Thenewly-createdfoldernowappearsinthelist.
CallListFolderNames
EndSub
SubListFolderNames()
DimiasInteger
DimstrResultsAsString
'Loopthroughallthetop-levelfoldernamesontheC:\drive
'inMyComputerandreporttheresults.
'.SearchScopes.Item(1)="MyComputer"
'.ScopeFolders.Item(2)="C:\"
WithApplication.FileSearch.SearchScopes.Item(1)._
ScopeFolder.ScopeFolders.Item(2)
Fori=1To.ScopeFolders.Count
strResults=strResults&.ScopeFolders._
Item(i).Name&vbCrLf
Nexti
Page 354
MsgBox"FolderNamesonC:\...."&vbCrLf&strResults
EndWith
EndSub
Page 356
ReleaseFocusMethodReleasestheuserinterfacefocusfromallcommandbars.
expression.ReleaseFocus
expressionRequired.AnexpressionthatreturnsaCommandBarsobject.
Page 357
Example
Thisexampleaddsthreeblankbuttonstothecommandbarnamed“Custom”andsetsthefocustothecenterbutton.Theexamplethenwaitsfivesecondsbeforereleasingtheuserinterfacefocusfromallcommandbars.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
WithmyBar
.Controls.AddType:=msoControlButton
.Controls.AddType:=msoControlButton
.Controls.AddType:=msoControlButton
.Visible=True
EndWith
SetmyControl=CommandBars("Custom").Controls(2)
WithmyControl
.SetFocus
EndWith
PauseTime=5'Setduration.
Start=Timer'Setstarttime.
DoWhileTimer<Start+PauseTime
DoEvents'Yieldtootherprocesses.
Loop
Finish=Timer
CommandBars.ReleaseFocus
Page 359
RemoveMethodRemovemethodasitappliestotheFileTypes,PropertyTests,and
SearchFoldersobjects.
Removesthespecifiedobjectfromthecollection.
expression.Remove(Index)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
IndexRequiredLong.Theindexnumberofthepropertytesttoberemoved.
RemovemethodasitappliestotheNewFileobject.
RemovesanitemfromtheNew<Item>taskpane.ReturnsaBoolean.
expression.Remove(FileName,Section,DisplayName,Action)
expressionRequired.AnexpressionthatreturnsaNewFileobject.
FileNameRequiredString.Thenameofthefilereference.
SectionOptionalVariant.Thesectionofthetaskpanewherethefilereferenceexists.CanbeanymsoFileNewSectionconstant.
DisplayNameOptionalVariant.Thedisplaytextofthefilereference.
ActionOptionalVariant.Theactiontakenwhenauserclicksontheitem.CanbeanymsoFileNewActionconstant.
RemovemethodasitappliestotheUserPermissionobject.
RemovesthespecifiedUserPermissionobjectfromthePermissioncollectionoftheactivedocument.
expression.Remove()
Page 360
expressionRequired.AnexpressionthatreturnsaUserPermissionobject.
Page 361
Remarks
TheUserPermissionobjectassociatesasetofpermissionsontheactivedocumentwithasingleuserandanoptionalexpirationdate.TheRemovemethodremovestheuserandthesetofuserpermissionsdeterminedbythespecifiedUserPermissionobject.
Page 362
Example
AsitappliestotheFileTypes,PropertyTests,andSearchFoldersobjects.
Thisexampleremovesthefirstsearchcriterionfromthecollection.
Application.FileSearch.PropertyTests.Remove(1)
AsitappliestotheNewFileobject.
ThisexampleremovesthespecifieditemfromtheMicrosoftWordNewDocumenttaskpane.
SubRemoveDocFromTaskPane()
Application.NewDocument.RemoveFileName:="C:\Newfile.doc",_
Section:=msoNewfromTemplate,DisplayName:="NewFile"
CommandBars("TaskPane").Visible=True
EndSub
AsitappliestotheUserPermissionobject.
Thefollowingexampleremovestheseconduser'spermissionsontheactivedocumentfromthedocument'sPermissioncollection.
DimirmPermissionAsOffice.Permission
DimirmUserPermAsOffice.UserPermission
SetirmPermission=ActiveWorkbook.Permission
SetirmUserPerm=irmPermission.Item(2)
irmUserPerm.Remove
MsgBox"Permissionremoved.",_
vbInformation+vbOKOnly,"IRMInformation"
SetirmUserPerm=Nothing
SetirmPermission=Nothing
Page 364
RemoveAllMethodRemovesallUserPermissionobjectsfromthePermissioncollectionoftheactivedocument.
expression.RemoveAll()
expressionRequired.AnexpressionthatreturnsaPermissionobject.
Page 365
Remarks
TheRemoveAllmethodremovesallUserPermissionsthathavebeenaddedtothePermissioncollectionanddisablesrestrictionsontheactivedocument.AftercallingtheRemoveAllmethod,theEnabledpropertyofthePermissionobjectreturnsFalseandtheCountpropertyreturns0(zero).
Page 366
Example
ThefollowingexampleusestheRemoveAllmethodtoremovealluserpermissionsandtodisablerestrictionsontheactivedocument.
DimirmPermissionAsOffice.Permission
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
irmPermission.RemoveAll
MsgBox"Allpermissionsremoved."&vbCrLf&_
"Count:"&irmPermission.Count&vbCrLf&_
"Enabled:"&irmPermission.Enabled,_
vbInformation+vbOKOnly,"IRMInformation"
Else
MsgBox"Thisdocumentisnotrestricted.",_
vbInformation+vbOKOnly,"IRMInformation"
EndIf
SetirmPermission=Nothing
Page 367
RemoveDocumentMethodRemovestheactivedocumentfromthesharedworkspace.
expression.RemoveDocument()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 368
Remarks
Iftheuserdoesnothavepermissiontoremovethesharedworkspacedocumentfromtheserver,thentheservercopyremainsintact,butthelocalcopyofthedocumentisdisconnectedfromthesharedworkspace.Inthecasewherethedocumenthasbeenopeneddirectlyfromtheworkspace,thenremovedfromtheworkspaceusingRemoveDocument,thedocumentmustbesavedtoanotherlocationbeforeclosing;otherwise,itwillremainintheworkspace.
UsetheDisconnectmethodtodetachthelocalcopyofthedocumentfromthesharedworkspacewithoutremovingthesharedcopy.
Page 369
Example
Thefollowingexampledetermineswhethertheactivedocumentisconnectedtoasharedworkspace,thenofferstheusertheoptionofremovingthedocumentfromtheworkspace.
DimrAsLong
IfActiveWorkbook.SharedWorkspace.ConnectedThen
r=MsgBox("Areyousureyouwanttoremovethisdocument?",_
vbQuestion+vbOKCancel,"Areyousure?")
Ifr=vbOKThen
ActiveWorkbook.SharedWorkspace.RemoveDocument
MsgBox"Thedocumenthasbeenremoved.",_
vbInformation+vbOKOnly,"Removed"
Else
MsgBox"Removalcancelled.",_
vbInformation+vbOKOnly,"StillInWorkspace"
EndIf
Else
MsgBox"Theactivedocumentisnotconnectedtoasharedworkspace.",_
vbInformation+vbOKOnly,"NotConnected"
EndIf
Page 371
RemoveItemMethodRemovesanitemfromacommandbarcomboboxcontrol.
NoteThepropertyfailswhenappliedtocontrolsotherthanlistcontrols.
expression.RemoveItem(Index)
expressionRequired.AnexpressionthatreturnsaCommandBarComboBoxobject.
IndexRequiredLong.Theitemtoberemovedfromthelist.
Page 372
Example
Thisexampledetermineswhethertherearemorethanthreeitemsinthespecifiedcombobox.Iftherearemorethanthreeitems,theexampleremovestheseconditem,altersthestyle,andsetsanewvalue.ItalsosetstheTagpropertyoftheparentobject(theCommandBarControlobject)toshowthatthelisthaschanged.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
WithmyBar
.Controls.AddType:=msoControlComboBox,ID:=1
.Visible=True
EndWith
WithCommandBars("Custom").Controls(1)
.AddItem"GetStockQuote",1
.AddItem"ViewChart",2
.AddItem"ViewFundamentals",3
.AddItem"ViewNews",4
.Caption="StockData"
.DescriptionText="ViewDataForStock"
EndWith
SetmyControl=myBar.Controls(1)
WithmyControl
If.ListCount>3Then
.RemoveItem2
.Style=msoComboNormal
.Text="NewDefault"
Setctrl=.Parent
EndIf
EndWith
Page 374
ResetMethodResetsabuilt-incommandbartoitsdefaultconfiguration,orresetsabuilt-incommandbarcontroltoitsoriginalfunctionandface.
expression.Reset
expressionRequired.AnexpressionthatreturnsaCommandBar,CommandBarControl,CommandBarButton,CommandBarPopup,orCommandBarComboBoxobject.
Page 375
Remarks
Resettingabuilt-incontrolrestorestheactionsoriginallyintendedforthecontrolandresetseachofthecontrol'spropertiesbacktoitsoriginalstate.Resettingabuilt-incommandbarremovescustomcontrolsandrestoresbuilt-incontrols.
Page 376
Example
Thisexampleusesthevalueofusertoadjustthecommandbarsaccordingtotheuserlevel.Ifuseris"Level1,"thecommandbarnamed"Custom"isdisplayed.Ifuserisanyothervalue,thebuilt-inVisualBasiccommandbarisresettoitsdefaultstateandthecommandbarnamed"Custom"isdisabled.
SetmyBar=CommandBars("Custom")
Ifuser="Level1"Then
myBar.Visible=True
Else
CommandBars("VisualBasic").Reset
myBar.Enabled=False
EndIf
Page 377
ResetFileListMethodResetsthelistoffilesforthecurrentAnswerWizardtothedefaultlistoffilesfortheMicrosoftOfficehostapplication.
expression.ResetFileList
expressionAnexpressionthatreturnsanAnswerWizardobject.
Page 378
Remarks
UsethismethodtorestoreallentriesinthecurrentAnswerWizardfilelisttothelistintheWindowsregistryforthehostapplication.Youcanestablishacustomdefaultfilelistintheregistrybyaddingthenamesofthecustomfilestotheappropriateregistrykey.
CautionIncorrectlyeditingtheregistrymayseverelydamageyouroperatingsystem,requiringyoutoreinstallit.Microsoftcannotguaranteethatproblemsresultingfromeditingtheregistryincorrectlycanberesolved.Beforeeditingtheregistry,backupanyvaluabledata.Forthemostrecentinformationaboutusingandprotectingyourcomputer'sregistry,seeMicrosoftWindowsHelp.
Page 379
Example
ThisexampleresetsthefilelistforthecurrentAnswerWizardandthendisplaysboththefilecountandthefilenamesinamessagebox.
DimcustomAnswerWizardAsAnswerWizard
DimstrFileListAsString
DimintCounterAsInteger
DimintNumFilesAsInteger
SetcustomAnswerWizard=Application.AnswerWizard
intCounter=1
customAnswerWizard.ResetFileList
strFileList=""
intNumFiles=customAnswerWizard.Files.Count
ForintCounter=1To(intNumFiles)
strFileList=strFileList&_
customAnswerWizard.Files.Item(intCounter)&Chr(13)
Next
MsgBox"Thereare"&customAnswerWizard.Files.Count&_
"filesavaialblethroughthisAnswerWizard:"&_
Chr(13)&strFileList
Page 380
ResetTipsMethodSomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ResetstheapplicationtipsthatappearintheOfficeAssistantballoon.
expression.ResetTips
expressionRequired.AnexpressionthatreturnsanAssistantobject.
Page 381
Remarks
TheResetTipsmethodcorrespondstotheResetmytipsbuttonontheOptionstabintheOfficeAssistantdialogbox.
Page 382
Example
ThisexampleresetstheapplicationtipsbeforemakingtheOfficeAssistantvisible.Aconfirmationballoonwillappear,tellingtheuserthathisorherapplicationtipshavebeenreset.
WithApplication.Assistant
.On=True
.Visible=True
.Animation=msoAnimationGreeting
.ResetTips
EndWith
Page 384
ResolveConflictMethodResolvesconflictsbetweenthelocalandtheservercopiesofashareddocument.
expression.ResolveConflict(SyncConflictResolution)
expressionRequired.AnexpressionthatreturnsaSyncobject.
SyncConflictResolutionRequiredMsoSyncConflictResolutionType.
MsoSyncConflictResolutionTypecanbeoneofthesesoSyncConflictResolutionTypeconstants.msoSyncConflictClientWins(0)msoSyncConflictServerWins(1)msoSyncConflictMerge(2)
Page 385
Remarks
UsetheResolveConflictmethodtoresolvedifferencesbetweenthelocalcopyoftheactivedocumentandtheservercopy.UsethemsoSyncConflictMergeoption(notavailableforaMicrosoftExcelWorkbook)tomergethechangesfromeachdocumentintotheother.ReplacetheservercopywithlocalchangesbyusingthemsoSyncConflictClientWinsoption,orreplacethelocalcopywiththechangedservercopybyusingthemsoSyncConflictServerWinsoption.
ThemsoSyncConflictMergeoptionmergeschangesmadetotheservercopyintothelocalcopy,butdoesnotactuallyresolvetheconflict.Inordertoresolvetheconflictwiththemergedchangeswinning,youmustsavetheactivedocumentaftermergingchanges,thencalltheResolveConflictmethodagainwiththemsoSyncConflictClientWinsoption.
TheResolveConflictmethodcanencounteraconflictconditioniftheclientisunawareofrecentchangestotheservercopyoftheshareddocument.CalltheGetUpdatemethodbeforecallingResolveConflicttorefreshthestatusoftheservercopyandtodetectapossibleconflict.
TheResolveConflictmethodraisesarun-timeerrorifthelocaldocumenthasunsavedchangesorifnoconflictexistsbetweenthe2copiesofthedocument.
Notalldocumentsynchronizationproblemsraisetrappablerun-timeerrors.AfterperforminganoperationusingtheSyncobject,it'sagoodideatochecktheStatusproperty;iftheStatuspropertyismsoSyncStatusError,checktheErrorTypepropertyforadditionalinformationonthetypeoferrorthathasoccurred.
Page 386
Example
Thefollowingexampleattemptstoresolveaconflictbymergingchangesbetweenthelocalandtheservercopiesoftheactivedocument.
DimobjSyncAsOffice.Sync
DimstrStatusAsString
SetobjSync=ActiveDocument.Sync
IfobjSync.Status=msoSyncStatusConflictThen
objSync.ResolveConflictmsoSyncConflictMerge
ActiveDocument.Save
objSync.ResolveConflictmsoSyncConflictClientWins
strStatus="Conflictresolvedbymergingchanges."
MsgBoxstrStatus,vbInformation+vbOKOnly,"SyncInformation"
EndIf
SetobjSync=Nothing
Page 387
RestoreMethodRestoresaprevioussavedversionofashareddocumentfromtheDocumentLibraryVersionscollection.
expression.Restore()
expressionRequired.AnexpressionthatreturnsaDocumentLibraryVersionobject.
Page 388
Remarks
UsetheRestoremethodtoreturntoanearliersavedversionoftheactivedocument.TheRestoremethoddoesseveralthings:
1. Itchangestheopenversionoftheshareddocumenttoread-onlymodebutleavesitopen.
2. Itopenstherestoredversioninread/writemode.3. Itsavestherestoredversiontotheserverasanewdocumentversion,
makingtherestoredversionthelatestversion.
TheRestoremethodraisesarun-timeerroriftheactivedocumenthaschangesthathavenotbeensaved.
Page 389
Example
Thefollowingexamplerestoresthepreviousversionoftheactivedocument.
DimdlvVersionsAsOffice.DocumentLibraryVersions
SetdlvVersions=ActiveDocument.DocumentLibraryVersions
dlvVersions(dlvVersions.Count-1).Restore
SetdlvVersions=Nothing
Page 390
SaveMethodUploadschangesmadeprogrammaticallytoaSharedWorkspaceLinkoraSharedWorkspaceTasktotheserver.
expression.Save()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceLinkoraSharedWorkspaceTaskobject.
Page 391
Remarks
UsetheSavemethodtouploadchangestotheserverafterchangingthepropertiesofasharedworkspacelinkortask.
Page 392
Example
ThefollowingexamplesetsanewDueDateforeachtaskinthesharedworkspaceanduploadsthechangestotheserverusingtheSavemethod.
DimswsTaskAsOffice.SharedWorkspaceTask
ConstdtmNewDueDateAsDate=#12/31/2005#
ForEachswsTaskInActiveWorkbook.SharedWorkspace.Tasks
swsTask.DueDate=dtmNewDueDate
swsTask.Save
Next
SetswsTask=Nothing
Page 393
SaveCopyAsMethodSavesthespecifiedHTMLprojectitemusinganewfilename.
expression.SaveCopyAs(Filename)
expressionAnHTMLProjectItemobject.
FilenameRequiredString.ThefullyqualifiedpathofthefiletowhichyouwanttosavetheHTMLprojectitem.
Page 394
Example
ThisexamplesavesacopyofthetextofthecurrentHTMLprojectitemtothefileNewScript.txt.
ActiveWorkbook.HTMLProject.HTMLProjectItems._
Item(1).SaveCopyAs("C:\NewScript.txt")
Page 395
SetAvoidRectangleMethodSomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
PreventstheOfficeAssistantballoonfrombeingdisplayedinaspecifiedareaofthescreen.
expression.SetAvoidRectangle(Left,Top,Right,Bottom)
expressionRequired.AnexpressionthatreturnsanAssistantobject.
Left,Top,Right,BottomRequiredLong.Thecoordinates(inpointsandrelativetothescreen)oftheareaofthescreenthattheOfficeAssistantballoonwillavoidwhenit'sdisplayed.
Page 396
Remarks
ThispropertyisintendedtopreventtheOfficeAssistantballoonfromoverlappingcustomdialogboxesandwizards.
Page 397
Example
ThisexamplepreventstheOfficeAssistantballoonrepresentedbythevariablemyBalloonfrombeingdisplayedintheregionofthescreendenotedbythespecifiedcoordinates.
SetmyBalloon=Assistant.NewBalloon
WithmyBalloon
.SetAvoidRectangle300,250,700,500
.Text="Cannotdisplayincoordinates"&_
"300,250,700,500."
.Show
EndWith
Page 399
SetFocusMethodMovesthekeyboardfocustothespecifiedcommandbarcontrol.Ifthecontrolisdisabledorisn'tvisible,thismethodwillfail.
Page 400
Remarks
Thefocusonthecontrolissubtle.Afteryouusethismethod,youwillnoticeathreedimensionalhighlightonthecontrol.Pressingthearrowkeyswillnavigateinthetoolbars,asifyouhadarrivedatthecontrolbypressingonlykeyboardcontrols.
expression.SetFocus
expressionRequired.AnexpressionthatreturnsaCommandBarControl,CommandBarButton,CommandBarPopup,orCommandBarComboBoxobject.
Page 401
Example
Thisexamplecreatesacommandbarnamed"Custom"andaddsaComboBoxcontrolandaButtoncontroltoit.TheexamplethenusestheSetFocusmethodtosetthefocustotheComboBoxcontrol.
SetfocusBar=CommandBars.Add(Name:="Custom")
WithCommandBars("Custom")
.Visible=True
.Position=msoBarTop
EndWith
SettestComboBox=CommandBars("Custom").Controls_
.Add(Type:=msoControlComboBox,ID:=1)
WithtestComboBox
.AddItem"FirstItem",1
.AddItem"SecondItem",2
EndWith
SettestButton=CommandBars("Custom").Controls_
.Add(Type:=msoControlButton)
testButton.FaceId=17
'Setthefocustothecombobox.
testComboBox.SetFocus
Page 402
SetSortOrderMethodSetsthesortorderformailmergedata.
expression.SetSortOrder(SortField1,SortAscending1,SortField2,SortAscending2,SortField3,SortAscending3)
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
SortField1RequiredString.Thefirstfieldonwhichtosortthemailmergedata.
SortAscending1OptionalBoolean.True(default)toperformanascendingsortonSortField1;Falsetoperformadescendingsort.
SortField2OptionalString.Thesecondfieldonwhichtosortthemailmergedata.Defaultisanemptystring.
SortAscending2OptionalBoolean.True(default)toperformanascendingsortonSortField2;Falsetoperformadescendingsort.
SortField3OptionalString.Thethirdfieldonwhichtosortthemailmergedata.Defaultisanemptystring.
SortAscending3OptionalBoolean.True(default)toperformanascendingsortonSortField3;Falsetoperformadescendingsort.
Page 403
Example
ThefollowingexamplesortsthedatasourcefirstaccordingtoZIPcodeindescendingorder,thenonlastnameandfirstnameinascendingorder.
SubSetDataSortOrder()
DimappOfficeAsOfficeDataSourceObject
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
appOffice.SetSortOrderSortField1:="ZipCode",_
SortAscending1:=False,SortField2:="LastName",_
SortField3:="FirstName"
EndSub
Page 405
ShowMethodShowmethodasitappliestotheBalloonobject.
Displaysthespecifiedballoonobject.ReturnsanMsoBalloonButtonTypeconstantthatindicateswhichbuttonorlabeltheuserclickedintheballoon.
MsoBalloonButtonTypecanbeoneoftheseMsoBalloonButtonTypeconstants.msoBalloonButtonAbortmsoBalloonButtonBackmsoBalloonButtonCancelmsoBalloonButtonClosemsoBalloonButtonIgnoremsoBalloonButtonNextmsoBalloonButtonNomsoBalloonButtonNullmsoBalloonButtonOKmsoBalloonButtonOptionsmsoBalloonButtonRetrymsoBalloonButtonSearchmsoBalloonButtonSnoozemsoBalloonButtonTipsmsoBalloonButtonYesmsoBalloonButtonYesToAll
expression.Show
expressionRequired.AnexpressionthatreturnsaBalloonobject.
ShowmethodasitappliestotheFileDialogobject.
DisplaysafiledialogboxandreturnsaLongindicatingwhethertheuserpressedtheactionbutton(-1)orthecancelbutton(0).WhenyoucalltheShow
Page 406
method,nomorecodewillexecuteuntiltheuserdismissesthefiledialogbox.InthecaseofOpenandSaveAsdialogboxes,usetheExecutemethodrightaftertheShowmethodtocarryouttheuser'saction.
expression.Show
expressionRequired.AnexpressionthatreturnsaFileDialogobject.
Page 407
Example
AsitappliestotheBalloonobject.
Thisexamplecreatesaballooncontainingtwoballoonlabelchoicesforsettingprinterorientation:PortraitandLandscape.TheexampleusesthereturnvaluefromtheShowmethodinaSelectCasestatementtodeterminewhichorientationtheuserhaschosen.
SetbalNew=Assistant.NewBalloon
WithbalNew
.Heading="Pleasechooseaprinterorientation"
.Labels(1).Text="Portrait"
.Labels(2).Text="Landscape"
.Button=msoButtonSetNone
EndWith
SelectCasebalNew.Show
Case1
'InsertcodetosetprintertoPortrait.
Case2
'InsertcodetosetprintertoLandscape.
EndSelect
Thisexamplecreatesaballooncontainingthreecommandbuttons:Yes,No,andCancel.TheexampleusesthereturnvaluefromtheShowmethodinaSelectCasestatementtodeterminethebuttonclickedbytheuser.
SetbalNew=Assistant.NewBalloon
WithbalNew
.Heading="Areyousureyouwanttosetthe"&_
"printerorientationtoLandscape?"
.BalloonType=msoBalloonTypeButtons
.Button=msoButtonSetYesNoCancel
EndWith
SelectCasebalNew.Show
CasemsoBalloonButtonCancel'UserselectedCancelbutton.
returnValue=MsgBox("Operationcanceled.",_
vbOKOnly,"PrinterMessage")
CasemsoBalloonButtonYes'UserselectedYesbutton.
returnValue=MsgBox("Printersetto"&_
"Landscape.",vbOKOnly,"PrinterMessage")
Page 408
CasemsoBalloonButtonNo'UserselectedNobutton.
returnValue=MsgBox("Printerorientationnot"&_
"reset.",vbOKOnly,"PrinterMessage")
EndSelect
AsitappliestotheFileDialogobject.
ThefollowingexampledisplaysaFilePickerdialogboxusingtheFileDialogobjectanddisplayseachselectedfileinamessagebox.
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Theuserpressedtheactionbutton.
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisastringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Thepathis:"&vrtSelectedItem
NextvrtSelectedItem
'TheuserpressedCancel.
Else
EndIf
EndWith
'Settheobjectvariabletonothing.
Setfd=Nothing
Page 411
ShowPopupMethodDisplaysacommandbarasashortcutmenuatthespecifiedcoordinatesoratthecurrentpointercoordinates.
NoteIfthePositionpropertyofthecommandbarisnotsettomsoBarPopup,thismethodfails.
expression.ShowPopup(x,y)
expressionRequired.AnexpressionthatreturnsaCommandBarobject.
xOptionalVariant.Thex-coordinateforthelocationoftheshortcutmenu.Ifthisargumentisomitted,thecurrentx-coordinateofthepointerisused.
yOptionalVariant.They-coordinateforthelocationoftheshortcutmenu.Ifthisargumentisomitted,thecurrenty-coordinateofthepointerisused.
Page 412
Example
Thisexamplecreatesashortcutmenucontainingtwocontrols.TheShowPopupmethodisusedtomaketheshortcutmenuvisible.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarPopup,Temporary:=False)
WithmyBar
.Controls.AddType:=msoControlButton,Id:=3
.Controls.AddType:=msoControlComboBox
EndWith
myBar.ShowPopup
Page 413
StartWizardMethodSomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
StartstheOfficeAssistantandreturnsaLongvaluethatidentifiesthesession.YoushouldusethismethodonlytoruntheOfficeAssistantinacustomwizard.
NoteThenumberreturnedbyStartWizardmethodisusedbytheActivateWizardandEndWizardmethods.
expression.StartWizard(On,Callback,PrivateX,Animation,CustomTeaser,Top,Left,Bottom,Right)
expressionRequired.AnexpressionthatreturnsanAssistantobject.
OnRequiredBoolean.TruetodisplaytheOfficedecisionballoon.TheOfficedecisionballoonaskstheuserwhetherheorshewantshelpwiththeactivecustomwizard.Itisn'tnecessarytousetheVisiblepropertytodisplaytheOfficeAssistantifyouspecifyTrueforthisargument.
CallbackRequiredString.ThenameofthecallbackprocedurerunbytheOfficedecisionballoonandthebranchballoon.ThebranchballoonallowstheusertochoosebetweencustomHelpyou'veprovidedforthewizardandstandardOfficeHelp.
PrivateXRequiredLong.Anumberthatidentifiestheballoonthatinitiatedthecallbackprocedure.
AnimationOptionalVariant.TheanimationtheOfficeAssistantperformswhenthismethodisused.ThedefaultvalueismsoAnimationGetWizardy.
CustomTeaserOptionalVariant.FalsetodisplaytheOfficedecisionballoon.
Top,Left,Bottom,RightOptionalVariant.Thepositionofthecorners(inpointsandrelativetothescreen)ofthecustomwizardformtheOfficeAssistantwillavoidwhentheOfficeAssistantappears.
Page 414
Remarks
Unlikecallbackproceduresusedbystandardmodelessballoons,thecallbackprocedurecalledbythemodelessdecisionandbranchballoonsdisplayedduringanOfficeAssistantwizardsessiontakesonlytwoarguments:anMsoWizardMsgTypeconstant,andtheuniquevaluespecifiedbythePrivateXargumentoftheStartWizardmethod.
Iftheuserclickstheleftbuttoninthedecisionorbranchballoon,theconstantmsoWizardMsgShowHelpispassedtothefirstargumentofthecallbackprocedure.Iftheuserclickstherightbutton,theconstantmsoWizardLocalStateOffispassed.(TheotherMsoWizardMsgTypeconstantsarepassedbytheActivateWizardmethodifyou’vespecifiedmsoWizardActResumeormsoWizardActSuspendfortheActargument.)InthecaseofmsoWizardMsgShowHelp,thecallbackprocedureshoulddisplaytheappropriateballoonforthecurrentpanelofthecustomwizard.AndinthecaseofmsoWizardLocalStateOff,thecallbackprocedureshouldhidethevisibleballoon.
Page 415
Example
ThisexamplestartstheOfficeAssistantaspartofaprocesstoprovideinformationwhileacustomwizardisrunning.ThevariablelHelpForWizissettothereturnvalueoftheStartWizardmethod,whichisLong.
lHelpForWiz=Assistant.StartWizard(On:=True,_
Callback:="myCallback",PrivateX:=23)
Page 416
UnsuspendMethodResumessynchronizationbetweenthelocalcopyandtheservercopyofashareddocument.
expression.Unsuspend()
expressionRequired.AnexpressionthatreturnsaSyncobject.
Page 417
Remarks
UsetheUnsuspendmethodtoresumedocumentsynchronizationwhentheStatuspropertyreturnsmsoSyncStatusSuspended.
Notalldocumentsynchronizationproblemsraisetrappablerun-timeerrors.AfterperforminganoperationusingtheSyncobject,it'sagoodideatochecktheStatusproperty;iftheStatuspropertyismsoSyncStatusError,checktheErrorTypepropertyforadditionalinformationonthetypeoferrorthathasoccurred.
Page 418
Example
Thefollowingexampleresumesdocumentsynchronizationifithasbeensuspended.
DimobjSyncAsOffice.Sync
SetobjSync=ActiveDocument.Sync
IfobjSync.Status=msoSyncStatusSuspendedThen
objSync.Unsuspend
MsgBox"Synchronizationresumed.",_
vbInformation+vbOKOnly,"SyncStatus"
EndIf
SetobjSync=Nothing
Page 419
UpdateMethodUpdatesthecontentsoftheCOMAddInscollectionfromthelistofadd-insstoredintheWindowsregistry.
expression.Update
expressionTheCOMAddInscollection.
Page 420
Remarks
BeforeyoucanuseagivenCOMadd-ininaMicrosoftOfficeapplication,thatadd-inmustberegisteredintheWindowsregistryasaCOMcomponentwithacorrespondingComponentCategoryID.NormallythesetupprogramforaCOMadd-inwilladdthenecessaryentriestotheregistry.
Page 421
Example
ThefollowingexampleupdatesthecontentsoftheCOMAddInscollectionfromthelistofadd-insstoredintheWindowsregistry.
Application.COMAddIns.Update
Page 422
ActionControlPropertyReturnstheCommandBarControlobjectwhoseOnActionpropertyissettotherunningprocedure.Iftherunningprocedurewasnotinitiatedbyacommandbarcontrol,thispropertyreturnsNothing.Read-only.
Page 423
Example
Thisexamplecreatesacommandbarnamed“Custom”,addsthreebuttonstoit,andthenusestheActionControlpropertyandtheTagpropertytodeterminewhichcommandbarbuttonwaslastclicked.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
SetbuttonOne=myBar.Controls.Add(Type:=msoControlButton)
WithbuttonOne
.FaceId=133
.Tag="RightArrow"
.OnAction="whichButton"
EndWith
SetbuttonTwo=myBar.Controls.Add(Type:=msoControlButton)
WithbuttonTwo
.FaceId=134
.Tag="UpArrow"
.OnAction="whichButton"
EndWith
SetbuttonThree=myBar.Controls.Add(Type:=msoControlButton)
WithbuttonThree
.FaceId=135
.Tag="DownArrow"
.OnAction="whichButton"
EndWith
myBar.Visible=True
ThewhichButtonsubroutinerespondstotheOnActionmethodanddetermineswhichcommandbarbuttonwaslastclicked.
SubwhichButton()
SelectCaseCommandBars.ActionControl.Tag
Case"RightArrow"
MsgBox("RightArrowbuttonclicked.")
Case"UpArrow"
MsgBox("UpArrowbuttonclicked.")
Case"DownArrow"
MsgBox("DownArrowbuttonclicked.")
EndSelect
EndSub
Page 425
ActiveMenuBarPropertyReturnsaCommandBarobjectthatrepresentstheactivemenubarinthecontainerapplication.Read-only.
Page 426
Example
Thisexampleaddsatemporarypop-upcontrolnamed"Custom"totheendoftheactivemenubar,andaddsacontrolnamed"Import"tothepop-upcontrol.
SetmyMenuBar=CommandBars.ActiveMenuBar
SetnewMenu=myMenuBar.Controls.Add(Type:=msoControlPopup,Temporary:=True)
newMenu.Caption="Custom"
Setctrl1=newMenu.CommandBar.Controls_
.Add(Type:=msoControlButton,Id:=1)
Withctrl1
.Caption="Import"
.TooltipText="Import"
.Style=msoButtonCaption
EndWith
Page 427
AdaptiveMenuPropertyTrueifanindividualmenuisenabledtouseadaptivemenus.Read/writeBoolean.
NoteThispropertywillnotfunctionwhiletheAdaptiveMenuspropertyissettoFalse.
Thispropertychecksorunchecksthecheckboxcontrolfortheoptiontoshowanindividualmenuasfullorpersonalized.OnlyrecentlyusedsubmenusshowupinamenuifthispropertyissettoTrue.AllsubmenusshowupifthispropertyissettoFalse.
Page 428
Example
ThisexamplesetstheAdaptiveMenupropertytoFalsefortheFilemenuintheMicrosoftOfficeapplicationyou’reworkingin.
CommandBars("File").AdaptiveMenu=False
NoteThispropertyworksonlywhenthespecifiedcommandbar("File"inthiscase)istheMSOBarTypePopup.ARunTimeErrorisreturnedwhenthispropertyisusedwithanothercommandbartypesuchasMSOBarTypeMenuBar.
Page 429
AdaptiveMenusPropertyTrueifadaptivemenusareenabledforallapplicationsinMicrosoftOffice.Read/writeBoolean.
ThispropertychecksorunchecksthecheckboxcontrolfortheoptiontoshowmenusinMicrosoftOfficeasfullorpersonalized.Thiscontrolissetinanyapplicationbydoingthefollowing:
1. OntheToolsmenu,selectCustomize.
2. SelecttheOptionstab.
3. TheAlwaysshowfullmenusoptionislocatedinthePersonalizedMenusandToolbarssection.
Page 430
Example
ThisexamplesetsthreeoptionsforallcommandbarsinMicrosoftOffice,includingcustomcommandbarsandthecontrolsonthem.
WithCommandBars
.LargeButtons=True
.DisplayFonts=True
.AdaptiveMenus=True
EndWith
Page 431
AllowMultiSelectPropertyTrueiftheuserisallowedtoselectmultiplefilesfromafiledialogbox.Read/writeBoolean.
expression.AllowMultiSelect
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 432
Remarks
ThispropertyhasnoeffectonFolderPickerdialogboxesorSaveAsdialogboxesbecauseusersshouldneverbeabletoselectmultiplefilesinthesetypesoffiledialogboxes.
Page 433
Example
ThefollowingexampledisplaysaFilePickerdialogboxusingtheFileDialogobjectanddisplayseachselectedfileinamessagebox.
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'Allowtheselectionofmultiplefiles.
.AllowMultiSelect=True
'UsetheShowmethodtodisplaythefilepickerdialogandreturntheuser'saction.
'Iftheuserpressestheactionbutton...
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Selecteditem'spath:"&vrtSelectedItem
Next
'IftheuserpressesCancel...
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Setfd=Nothing
Page 436
AnimationPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ReturnsorsetsananimationactionfortheOfficeAssistant.WhenthispropertyisappliedtotheAssistantobjectandtheAssistantsupportsthespecifiedanimation,theAssistantisanimatedimmediately(iftheAssistantisvisibleandenabled).WhenthispropertyisappliedtotheBalloonobject,theAssistantisanimatedonlywhiletheballoonisdisplayed.Read/writeMsoAnimationType.
MsoAnimationTypecanbeoneoftheseMsoAnimationTypeconstants.msoAnimationAppearmsoAnimationBeginSpeakingmsoAnimationCharacterSuccessMajormsoAnimationCheckingSomethingmsoAnimationDisappearmsoAnimationEmptyTrashmsoAnimationGestureDownmsoAnimationGestureLeftmsoAnimationGestureRightmsoAnimationGestureUpmsoAnimationGetArtsymsoAnimationGetAttentionMajormsoAnimationGetAttentionMinormsoAnimationGetTechymsoAnimationGetWizardymsoAnimationGoodbyemsoAnimationGreetingmsoAnimationIdlemsoAnimationListensToComputermsoAnimationLookDownmsoAnimationLookDownLeftmsoAnimationLookDownRight
Page 437
msoAnimationLookLeftmsoAnimationLookRightmsoAnimationLookUpmsoAnimationLookUpLeftmsoAnimationLookUpRightmsoAnimationPrintingmsoAnimationRestPosemsoAnimationSavingmsoAnimationSearchingmsoAnimationSendingMailmsoAnimationThinkingmsoAnimationWorkingAtSomethingmsoAnimationWritingNotingSomething
Page 438
Remarks
“Clippit”isthedefaultAssistant,andmsoAnimationIdleisthedefaultanimationtypefortheAssistant.
DependingontheselectedAssistant,settingtheAnimationpropertymayormaynotresultinanobviousanimation.However,allMsoAnimationTypeconstantsarevalidforallAssistants.Notethatdifferentconstantsmayproducethesameanimation.
ThefollowingMsoAnimationTypeconstantsrepresentanimationsthatrepeatthespecifiedactionuntiltheAssistantisdismissedoruntiltheAnimationpropertyisresetwithanotheranimation:
msoAnimationCheckingSomething
msoAnimationGetTechy
msoAnimationListensToComputer
msoAnimationSearching
msoAnimationThinking
msoAnimationWorkingAtSomething
msoAnimationWritingNotingSomething
Page 439
Example
ThisexampledisplaystheOfficeAssistantinaspecificlocationanditsetsseveraloptionsbeforemakingtheAssistantvisible.
WithAssistant
.On=True
.Visible=True
.MovexLeft:=400,yTop:=300
.MoveWhenInTheWay=True
.TipOfDay=True
.Animation=msoAnimationGreeting
EndWith
Page 440
ApplicationPropertyReturnsanApplicationobjectthatrepresentsthecontainerapplicationfortheobject(youcanusethispropertywithanAutomationobjecttoreturnthatobject'scontainerapplication).
expression.Application
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 441
Example
ThisexamplereturnsthenameoftheapplicationinwhichthecommandbarnamedStandardwascreatedanddisplaysthisresultinamessagebox.
SetAppobj=CommandBars("Standard").Application
MsgBoxAppobj
Page 442
AssignedToPropertyReturnsorsetstheSharedWorkspaceMembertowhomthetaskisassigned.Read/writeString.
expression.AssignedTo()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceTaskobject.
Page 443
Remarks
TheoptionalAssignedTopropertyofasharedworkspacetaskreturnsthedisplaynameorNamepropertyoftheSharedWorkspaceMembertowhomthetaskisassigned.However,usetheDomainNamepropertyofaSharedWorkspaceMembertosetthisproperty.
Page 444
Example
ThefollowingexampleusestheAssignedTopropertytoreassignallsharedworkspacetaskscurrentlyassignedtooneworkspacemembertoadifferentmember,usingthemember'sNamewhenreadingthepropertyandDomainNamewhenwritinganewvalueforit.
DimswsTaskAsOffice.SharedWorkspaceTask
ForEachswsTaskInActiveWorkbook.SharedWorkspace.Tasks
Debug.PrintswsTask.AssignedTo
IfswsTask.AssignedTo="NewEmployee"Then
swsTask.AssignedTo="MYCOMPANY\user123"
EndIf
Next
SetswsTask=Nothing
Page 445
AssistWithAlertsPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantballoondeliversapplicationalertswhentheOfficeAssistantisvisible.Read/writeBoolean.
Page 446
Remarks
TheAssistWithAlertspropertycorrespondstotheDisplayalertsoptionunderUsetheOfficeAssistantontheOptionstabintheOfficeAssistantdialogbox.
IfthispropertyissettoFalse,theapplicationdisplaysalertsindialogboxes.
Page 447
Example
ThisexamplesetstheOfficeAssistanttobedisplayedwheneveranapplicationalertisgenerated.
WithAssistant
.On=True
.Visible=True
.AssistWithHelp=True
.AssistWithAlerts=True
.Animation=msoAnimationGetAttentionMajor
EndWith
Page 448
AssistWithHelpPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantappearswhentheuserpressestheF1keytodisplayHelp.Read/writeBoolean.
NoteThispropertyisobsoletebuthasbeenretainedforcompatibilitywithcodewritteninpreviousversionsofMicrosoftOffice.
Page 449
Remarks
TheAssistWithHelppropertycorrespondstotheRespondtoF1keyoptionunderUsetheOfficeAssistantontheOptionstabintheOfficeAssistantdialogbox.
IfthispropertyissettoFalse,theHelpTopicsdialogboxappearsinsteadoftheOfficeAssistant.
Page 450
Example
ThisexampledisplaystheOfficeAssistantwhenevertheuserpressestheF1keytodisplayHelp.
WithAssistant
.On=True
.Visible=True
.AssistWithHelp=True
.AssistWithAlerts=True
.Animation=msoAnimationGetAttentionMajor
EndWith
Page 451
AssistWithWizardsPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantprovidesonlineHelpwithwizards.Read/writeBoolean.
Page 452
Remarks
TheAssistWithWizardspropertycorrespondstotheHelpwithwizardsoptionunderUsetheOfficeAssistantontheOptionstabintheOfficeAssistantdialogbox.
Page 453
Example
ThisexamplesetstheOfficeAssistanttoprovideHelpinformationaboutwizards.
Assistant.AssistWithWizards=True
Page 454
AttachCertificatePropertyTrueifthedigitalcertificatethatcorrespondstothespecifiedSignatureobjectisattachedtothedocument.Read/writeBoolean.
expression.AttachCertificate
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 455
Example
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandcallthisfunction.Thefunctionwilltesttomakesurethatthedigitalsignaturethattheuserselectswillnotexpireinlessthan12months.Ifitwillexpire,thecertificateisn'tattached.
FunctionAddSignature()AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
sig.AttachCertificate=True
'TesttomakesurethatthenewSignatureobject
'doesn'texpiretoosoon.Thisexpressioncalculates
'thenumberofmonthsuntiltheSignatureobjectexpires.
IfDateDiff("m",sig.SignDate,sig.ExpireDate)<12Then
MsgBox"Thiscertificatewillexpireinlessthan1year."&vbCrLf&_
"Pleaseuseanewercertificate."
AddSignature=False
sig.Delete
Else
AddSignature=True
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 458
BalloonErrorPropertyReturnsavaluethatindicatesthelastrecordedballoonerror.Read-onlyMsoBalloonErrorType.
MsoBalloonErrorTypecanbeoneoftheseMsoBalloonErrorTypeconstants.msoBalloonErrorBadCharacterTheballooncontainsanASCIIcontrolcharacterotherthanCRorLFandlessthan32.msoBalloonErrorBadPictureRefTheballooncontainsagraphicthatcouldn'tbedisplayedbecausethefiledoesn'texistorbecausethegraphicisn'tavalid.BMPor.WMFfile.msoBalloonErrorBadReferenceTheballooncontainsanunrecognizedorunsupportedreference.msoBalloonErrorButtonlessModalTheballoonyouattemptedtodisplayismodal,butitcontainsnobuttons.Theballoonwon'tbeshownbecauseitcan'tbedismissed.msoBalloonErrorButtonModelessTheballoonyouattemptedtodisplayismodeless,containsbuttons,andhasnoprocedureassignedtotheCallbackproperty.Theballoonwon'tbeshownbecauseacallbackprocedureisrequiredformodelessballoons.msoBalloonErrorCharNotTopmostForModalThemodalballoonwasrequestedbyanapplicationthatisn’ttheactiveapplication.MicrosoftOfficerendersballoonsfortheactive(topmost)applicationonly.msoBalloonErrorCOMFailureTheballooncouldnotbedisplayedbecauseofaCOMfailure.msoBalloonErrorNoneNoerrorwasencountered.msoBalloonErrorOtherTheballoonwon'tappearbecausesomeothererroroccurred,suchasanothermodalballoonisalreadyactive.msoBalloonErrorOutOfMemoryTheballoonwon'tappearbecausethereisinsufficientmemory.msoBalloonErrorTooBigTheballoonistoobigtoappearonthescreen.msoBalloonErrorTooManyControlsTheballooncontainsmorethantwentycontrols(checkboxesorlabels).
Page 459
Example
Thisexamplecreatesaballoonthatgeneratesanerror.Theerrorisgeneratedbecausetheballooniscreatedwithoutawaytodismissit:thebuttontypeissettomsoButtonSetNoneandthedefaultballoonmodeismsoModeModal,resultinginabuttonless,modalballoon.Notethatthere'snowaytodismissabuttonlessmodalballoon.
WithApplication.Assistant
With.NewBalloon
.Heading="Thiswillnevershow."
.Text="Imagineaballoonhere."
.Button=msoButtonSetNone
.Show
EndWith
.Visible=True
If.BalloonError=msoBalloonErrorButtonlessModalThen
MsgBox"Youneedabuttontodismisstheballoon."
EndIf
EndWith
Page 461
BalloonTypePropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ReturnsorsetsthetypeofballoontheOfficeAssistantuses.WhenyoucreateaBalloonobject,thispropertyisinitiallysettomsoBalloonTypeButtons.Read/writeMsoBalloonType.
MsoBalloonTypecanbeoneoftheseMsoBalloonTypeconstants.msoBalloonTypeBulletsmsoBalloonTypeButtonsmsoBalloonTypeNumbers
Page 462
Example
Thisexamplecreatesaninstructionballoonthatexplainshowtoselectaprinter.Theballoonismodeless,sotheusercanfollowtheinstructionsintheballoonandkeeptheballoonvisibleasheorsheworks.
Setbln=Assistant.NewBalloon
Withbln
.Heading="InstructionsforChoosingaPrinter."
.Text="ClickOKwhenyou'vechosenaprinter."
.Labels(1).Text="FromtheFilemenu,choosePrint."
.Labels(2).Text="ClickSetup."
.Labels(3).Text="Selectthenameoftheprinter."
.BalloonType=msoBalloonTypeNumbers
.Mode=msoModeModeless
.Callback="ProcessPrinter"
.Button=msoButtonSetOK
.Show
EndWith
Page 464
BeginGroupPropertyTrueifthespecifiedcommandbarcontrolappearsatthebeginningofagroupofcontrolsonthecommandbar.Read/writeBoolean.
Page 465
Example
Thisexamplebeginsanewgroupwiththelastcontrolontheactivemenubar.
SetmyMenuBar=CommandBars.ActiveMenuBar
SetlastMenu=myMenuBar_
.Controls(myMenuBar.Controls.Count)
lastMenu.BeginGroup=True
Page 467
BuiltInPropertyTrueifthespecifiedcommandbarorcommandbarcontrolisabuilt-incommandbarorcontrolofthecontainerapplication.Falseifit'sacustomcommandbarorcontrol,orifit'sabuilt-incontrolwhoseOnActionpropertyhasbeenset.Read-onlyBoolean.
Page 468
Example
Thisexampledeletesallcustomcommandbarsthataren'tvisible.
foundFlag=False
deletedBars=0
ForEachbarInCommandBars
If(bar.BuiltIn=False)And(bar.Visible=False)Then
bar.Delete
foundFlag=True
deletedBars=deletedBars+1
EndIf
Next
IfNotfoundFlagThen
MsgBox"Nocommandbarshavebeendeleted."
Else
MsgBoxdeletedBars&"customcommandbar(s)deleted."
EndIf
Page 470
BuiltInFacePropertyTrueifthefaceofacommandbarbuttoncontrolisitsoriginalbuilt-inface.ThispropertycanonlybesettoTrue,whichwillresetthefacetothebuilt-inface.Read/writeBoolean.
Page 471
Example
Thisexampledetermineswhetherthefaceofthefirstcontrolonthecommandbarnamed"Custom"isitsbuilt-inbuttonface.Ifitis,theexamplecopiesthebuttonfacetotheClipboard.
SetmyControl=CommandBars("MyCustomBar").Controls(1)
WithmyControl
If.BuiltInFace=TrueThen.CopyFace
EndWith
Page 473
ButtonPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ReturnsorsetsthetypeofbuttondisplayedatthebottomoftheOfficeAssistantballoon.WhenyoucreateaBalloonobject,thispropertyisinitiallysettomsoButtonSetOK.Read/writeMsoButtonSetType.
MsoButtonSetTypecanbeoneoftheseMsoButtonSetTypeconstants.msoButtonSetAbortRetryIgnoremsoButtonSetBackClosemsoButtonSetBackNextClosemsoButtonSetBackNextSnoozemsoButtonSetCancelmsoButtonSetNextClosemsoButtonSetNonemsoButtonSetOKmsoButtonSetOkCancelmsoButtonSetRetryCancelmsoButtonSetSearchClosemsoButtonSetTipsOptionsClosemsoButtonSetYesAllNoCancelmsoButtonSetYesNomsoButtonSetYesNoCancel
Page 474
Example
Thisexampledisplaysaballoonthatcontainsaheading,text,threeregionchoices,andtwocommandbuttons(OKandCancel).
WithAssistant.NewBalloon
.Heading="RegionalSalesData"
.Text="Selectaregion"
Fori=1To3
.CheckBoxes(i).Text="Region"&i
Next
.Button=msoButtonSetOkCancel
.Show
EndWith
Page 475
ButtonNamePropertySetsorreturnsaStringrepresentingthetextthatisdisplayedontheactionbuttonofafiledialogbox.Bydefault,thispropertyissettothestandardtextforthetypeoffiledialogbox.Forexample,inthecaseoftheOpendialogbox,thepropertyissetto"Open"bydefault.Thisstringislimitedtofifty-onecharacters.Read/write.
expression.ButtonName
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 476
Example
ThefollowingexampledisplaysaFilePickerdialogboxusingtheFileDialogobjectanddisplayseachselectedfileinamessagebox.
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'Changethetextontheactionbutton.
.ButtonName="Archive"
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Iftheuserpressestheactionbutton...
If.Show=-1Then
'StepthrougheachStringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Selecteditem'spath:"&vrtSelectedItem
NextvrtSelectedItem
'IftheuserpressesCancel...
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Setfd=Nothing
Page 478
CallbackPropertySetsthenameoftheproceduretorunfromamodelessballoon.Read/writeString.
Page 479
Remarks
TheprocedureyouspecifyfortheCallbackpropertymustbewrittentoreceiveeithertwoorthreearguments,dependingonwhatyouusethepropertywith.IfyouusetheCallbackpropertywithawizard,youmustwritetheproceduretoreceivetwoarguments:alongintegerthatrepresentsthemsoBalloonButtonTypevalueofthebuttonthattheuserclicked,andalongintegerthatuniquelyidentifiestheballoon.IfyouusetheCallbackpropertywithamodelessballoon,youmustwritetheproceduretoreceivethreearguments:theBalloonobjectthatcalledtheprocedure;alongintegerthatrepresentsthemsoBalloonButtonTypevalueofthebuttontheuserclicked;andalongintegerthatuniquelyidentifiestheballoonthatcalledtheprocedure,asdenotedintheballoon’sPrivateproperty.
ThecallbackproceduremustcontainatleastoneconditionunderwhichtheClosemethodisappliedtotheBalloonobjectthatispassedtoit;otherwise,themodelessballooncannotbedismissed.
Ifyouspecifyaprocedurethatisstoredinaseparateclassmodule,youmustincludethemodulenameinthevalueassignedtotheCallbackproperty(forexample,"Sheet1.MyCallback).
Page 480
Example
Thisexampledisplaysaballoonthatcontainsabuttonforeachofthreeprinters.Whenevertheuserclicksoneofthesebuttons,theProcessPrintercallbackprocedureisrunandtheballoonisclosed.
SubselectPrinter()
Setbln=Assistant.NewBalloon
Withbln
.Heading="SelectaPrinter."
.Labels(1).Text="NetworkPrinter"
.Labels(2).Text="LocalPrinter"
.Labels(3).Text="LocalColorPrinter"
.BalloonType=msoBalloonTypeButtons
.Mode=msoModeModeless
.Callback="ProcessPrinter"
.Show
EndWith
EndSub
SubProcessPrinter(blnAsBalloon,lbtnAsLong,_
lPrivAsLong)
Assistant.Animation=msoAnimationPrinting
SelectCaselbtn
Case-1
'Insertnetworkprinter-specificcode.
Case-2
'Insertlocalprinter-specificcode.
Case-3
'Insertcolorprinter-specificcode.
EndSelect
bln.Close
EndSub
Page 482
CaptionPropertyReturnsorsetsthecaptiontextforacommandbarcontrol.Read/writeString.
NoteAcontrol'scaptionisalsodisplayedasitsdefaultScreenTip.
Page 483
Example
Thisexampleaddsacommandbarcontrolwithaspellingcheckerbuttonfacetoacustomcommandbar,andthenitsetsthecaptionto"Spellingchecker."
SetmyBar=CommandBars.Add(Name:="Custom",_
Position:=msoBarTop,Temporary:=True)
myBar.Visible=True
SetmyControl=myBar.Controls_
.Add(Type:=msoControlButton,Id:=2)
WithmyControl
.DescriptionText="Startsthespellingchecker"
.Caption="Spellingchecker"
EndWith
Page 484
CheckboxesPropertyReturnstheBalloonCheckboxescollectionthatrepresentsallthecheckboxescontainedinthespecifiedballoon.Read-only.
Forinformationaboutreturningasinglememberofacollection,seeReturninganObjectfromaCollection.
Page 485
Example
Thisexamplecreatesaballoonwithaheading,text,andthreeregionchoices.WhentheuserclicksOKintheballoon,datafortheselectedregionorregionsisprinted.
WithAssistant.NewBalloon
.Heading="RegionalSalesData"
.Text="Selecttheregion(s)youwanttoprint."
Fori=1To3
.CheckBoxes(i).Text="Region"&i
Next
.Button=msoButtonSetOkCancel
If.Show=msoBalloonButtonOKThen
dataPrinted=0
Fori=1To3
If.CheckBoxes(i).Checked=TrueThen
'Codetoprintregiondata.
dataPrinted=dataPrinted+1
MsgBox"Region"&i&"dataprinted."
EndIf
Next
IfdataPrinted=0ThenMsgBox"Nodataprinted."
EndIf
EndWith
Page 486
CheckedPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueifthespecifiedcheckboxintheOfficeAssistantballoonischecked.Read/writeBoolean.
Page 487
Example
Thisexamplecreatesaballoonwithaheading,text,andthreeregionchoices.WhentheuserclicksOKintheballoon,datafortheselectedregionorregionsisprinted.
WithAssistant.NewBalloon
.Heading="RegionalSalesData"
.Text="Selecttheregion(s)youwanttoprint."
Fori=1To3
.CheckBoxes(i).Text="Region"&i
Next
.Button=msoButtonSetOkCancel
If.Show=msoBalloonButtonOKThen
dataPrinted=0
Fori=1To3
If.CheckBoxes(i).Checked=TrueThen
'Codetoprintregiondata.
dataPrinted=dataPrinted+1
MsgBox"Region"&i&"dataprinted."
EndIf
Next
IfdataPrinted=0ThenMsgBox"Nodataprinted."
EndIf
EndWith
Page 488
ColumnPropertyReturnsorsetsaStringthatrepresentsthenameofthefieldinthemailmergedatasourcetouseinthefilter.Read/write.
expression.Column
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 489
Example
ThefollowingexamplechangesanexistingfiltertoremovefromthemailmergeallrecordsthatdonothaveaRegionfieldequalto"WA".
SubSetQueryCriterion()
DimappOfficeAsOffice.OfficeDataSourceObject
DimintItemAsInteger
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Filters
ForintItem=1To.Count
With.Item(intItem)
If.Column="Region"Then
.Comparison=msoFilterComparisonNotEqual
.CompareTo="WA"
If.Conjunction="Or"Then.Conjunction="And"
EndIf
EndWith
NextintItem
EndWith
EndSub
Page 490
ColumnsPropertyReturnsanODSOColumnsobjectthatrepresentsthefieldsinadatasource.
expression.Columns
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 491
Example
Thefollowingexampledisplaysthefieldnamesinthedatasourceattachedtotheactivepublication.
SubShowFieldNames()
DimappOfficeAsOfficeDataSourceObject
DimintCountAsInteger
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Columns
ForintCount=1To.Count
MsgBox"FieldName:"&.Item(intCount).Name
Next
EndWith
EndSub
Page 493
CommandBarPropertyReturnsaCommandBarobjectthatrepresentsthemenudisplayedbythespecifiedpop-upcontrol.Read-only.
Page 494
Example
ThisexamplesetsthevariablefourthLeveltothefourthcontrolonthecommandbarnamed"Drawing."
SetfourthLevel=CommandBars("Drawing")_
.Controls(1).CommandBar.Controls(4)
Page 495
CommandBarsPropertyReturnsaCommandBarscollection.
expression.CommandBars
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 496
Example
ThefollowingexamplereturntheCommandBarscollectionfromtheMsoEnvelopeobjectinMicrosoftWord.
DimcbarsAsCommandBars
Setcbars=Application.ActiveDocument.MailEnvelope.Commandbars
Page 497
CommentsPropertyReturnsanyoptionalcommentsassociatedwiththespecifiedversionoftheshareddocument.Read-onlyString.
expression.Comments()
expressionRequired.AnexpressionthatreturnsaDocumentLibraryVersionobject.
Page 498
Remarks
Ausercanattachversioncommentsthroughthedocumentlibraryuserinterfacewhencheckinginadocumentthatwaspreviouslycheckedout.
Page 499
Example
Thefollowingexamplelistscommentsandotherpropertiesforeachversionofashareddocument.
DimdlvVersionsAsOffice.DocumentLibraryVersions
DimdlvVersionAsOffice.DocumentLibraryVersion
DimstrVersionInfoAsString
SetdlvVersions=ActiveDocument.DocumentLibraryVersions
IfdlvVersions.IsVersioningEnabledThen
strVersionInfo="Thisdocumenthas"&_
dlvVersions.Count&"versions:"&vbCrLf
ForEachdlvVersionIndlvVersions
strVersionInfo=strVersionInfo&_
"-Version#:"&dlvVersion.Index&vbCrLf&_
"-Modifiedby:"&dlvVersion.ModifiedBy&vbCrLf&_
"-Modifiedon:"&dlvVersion.Modified&vbCrLf&_
"-Comments:"&dlvVersion.Comments&vbCrLf
Next
Else
strVersionInfo="Versioningnotenabledforthisdocument."
EndIf
MsgBoxstrVersionInfo,vbInformation+vbOKOnly,"VersionInformation"
SetdlvVersion=Nothing
SetdlvVersions=Nothing
Page 500
CompareToPropertyReturnsorsetsaStringthatrepresentsthetexttocompareinthequeryfiltercriterion.Read/write.
expression.CompareTo
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 501
Example
ThefollowingexamplechangesanexistingfiltertoremovefromthemailmergeallrecordsthatdonothaveaRegionfieldequalto"WA".
SubSetQueryCriterion()
DimappOfficeAsOffice.OfficeDataSourceObject
DimintItemAsInteger
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Filters
ForintItem=1To.Count
With.Item(intItem)
If.Column="Region"Then
.Comparison=msoFilterComparisonNotEqual
.CompareTo="WA"
If.Conjunction="Or"Then.Conjunction="And"
EndIf
EndWith
NextintItem
EndWith
EndSub
Page 503
ComparisonPropertyReturnsorsetsanMsoFilterComparisonconstantthatrepresentshowtocomparetheColumnandCompareToproperties.Read/write.
MsoFilterComparisoncanbeoneoftheseMsoFilterComparisonconstants.msoFilterComparisonContainsmsoFilterComparisonEqualmsoFilterComparisonGreaterThanmsoFilterComparisonGreaterThanEqualmsoFilterComparisonIsBlankmsoFilterComparisonIsNotBlankmsoFilterComparisonLessThanmsoFilterComparisonLessThanEqualmsoFilterComparisonNotContainsmsoFilterComparisonNotEqual
expression.Comparison
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 504
Example
ThefollowingexamplechangesanexistingfiltertoremovefromthemailmergeallrecordsthatdonothaveaRegionfieldequalto"WA".
SubSetQueryCriterion()
DimappOfficeAsOffice.OfficeDataSourceObject
DimintItemAsInteger
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Filters
ForintItem=1To.Count
With.Item(intItem)
If.Column="Region"Then
.Comparison=msoFilterComparisonNotEqual
.CompareTo="WA"
If.Conjunction="Or"Then.Conjunction="And"
EndIf
EndWith
NextintItem
EndWith
EndSub
Page 506
ConditionPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
Returnstheconditionofthespecifiedsearchcriteria.Read-onlyMsoCondition.
MsoConditioncanbeoneoftheseMsoConditionconstants.msoConditionAnyNumberBetweenmsoConditionAnytimemsoConditionAnytimeBetweenmsoConditionAtLeastmsoConditionAtMostmsoConditionBeginsWithmsoConditionDoesNotEqualmsoConditionEndsWithmsoConditionEqualsmsoConditionFileTypeAllFilesmsoConditionFileTypeBindersmsoConditionFileTypeCalendarItemmsoConditionFileTypeContactItemmsoConditionFileTypeDatabasesmsoConditionFileTypeDataConnectionFilesmsoConditionFileTypeDesignerFilesmsoConditionFileTypeEPaperFilesmsoConditionFileTypeExcelWorkbooksmsoConditionFileTypeJournalItemmsoConditionFileTypeMailItemmsoConditionFileTypeNoteItemmsoConditionFileTypeOfficeFilesmsoConditionFileTypeOutlookItemsmsoConditionFileTypePhotoDrawFilesmsoConditionFileTypePowerPointPresentations
Page 507
msoConditionFileTypeProjectFilesmsoConditionFileTypePublisherFilesmsoConditionFileTypeTaskItemmsoConditionFileTypeTemplatesmsoConditionFileTypeVisioDocumentsmsoConditionFileTypeWebPagesmsoConditionFileTypeWordDocumentsmsoConditionFreeTextmsoConditionIncludesmsoConditionIncludesFormsOfmsoConditionIncludesNearEachOthermsoConditionIncludesPhrasemsoConditionInTheLastmsoConditionInTheNextmsoConditionIsExactlymsoConditionIsNomsoConditionIsNotmsoConditionIsYesmsoConditionLastMonthmsoConditionLastWeekmsoConditionLessThanmsoConditionMoreThanmsoConditionNextMonthmsoConditionNextWeekmsoConditionOnmsoConditionOnOrAftermsoConditionOnOrBeforemsoConditionThisMonthmsoConditionThisWeekmsoConditionTodaymsoConditionTomorrowmsoConditionYesterday
Page 508
Example
Thisexamplereturnstheconditionvalueforsearchcriteriaforthefirstpropertytest.
WithApplication.FileSearch.PropertyTests(1)
MsgBox"Theconditionyou'vesetis:"&.Condition
EndWith
Page 510
ConjunctionPropertyReturnsorsetsanMsoFilterConjunctionconstantthatrepresentshowafiltercriterionrelatestootherfiltercriteriaintheODSOFiltersobject.Read/write.
MsoFilterConjunctioncanbeoneoftheseMsoFilterConjunctionconstants.msoFilterConjunctionAndmsoFilterConjunctionOr
expression.Conjunction
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 511
Example
ThefollowingexamplechangesanexistingfiltertoremovefromthemailmergeallrecordsthatdonothaveaRegionfieldequalto"WA".
SubSetQueryCriterion()
DimappOfficeAsOffice.OfficeDataSourceObject
DimintItemAsInteger
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
WithappOffice.Filters
ForintItem=1To.Count
With.Item(intItem)
If.Column="Region"Then
.Comparison=msoFilterComparisonNotEqual
.CompareTo="WA"
If.Conjunction="Or"Then.Conjunction="And"
EndIf
EndWith
NextintItem
EndWith
EndSub
Page 512
ConnectPropertyReturnsorsetsthestateoftheconnectionforthespecifiedCOMAddInobject.Read/writeBoolean.
Page 513
Remarks
TheConnectpropertyreturnsTrueiftheadd-inisactive;itreturnsFalseiftheadd-inisinactive.Anactiveadd-inisregisteredandconnected;aninactiveadd-inisregisteredbutnotcurrentlyconnected.
Page 514
Example
ThefollowingexampledisplaysamessageboxthatindicateswhetherCOMadd-inoneisregisteredandcurrentlyconnected.
IfApplication.COMAddIns(1).ConnectThen
MsgBox"Theadd-inisconnected."
Else
MsgBox"Theadd-inisnotconnected."
EndIf
Page 515
ConnectedPropertyReturnsaBooleanvaluethatindicateswhetherornottheactivedocumentiscurrentlysavedinandconnectedtoasharedworkspace.Read-onlyBoolean.
expression.Connected
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 516
Remarks
UsetheDisconnectmethodoftheSharedWorkspaceobjecttodisconnectthelocalcopyoftheactivedocumentfromthesharedworkspace.UsetheRemoveDocumentmethodtoremovethedocumentfromthesharedworkspace.
Page 517
Example
ThefollowingexamplecheckstheConnectedpropertytodeterminewhethertheactivedocumentisalreadysavedinasharedworkspace.
IfActiveWorkbook.SharedWorkspace.ConnectedThen
MsgBox"Thisdocumentisalreadysavedinasharedworkspace."
EndIf
Page 519
ConnectorPropertyReturnstheconnectorbetweentwosimilarpropertytestvalues.ThedefaultvalueismsoConnectorAnd.Read-onlyMsoConnector.
MsoConnectorcanbeoneoftheseMsoConnectorconstants.msoConnectorAndmsoConnectorOr
Page 520
Remarks
Aconnectorspecifieswhethertwosimilarsearchcriteriawillbecombinedtoformonepropertytest(aswithmsoConnectorAnd)ortreatedindependently(aswithmsoConnectorOr).
Page 521
Example
Thisexampledisplaysamessagethatdescribeshowthesearchcriteriawillbeevaluatedinafilesearch.
WithApplication.FileSearch.PropertyTests(1)
If.Connector=msoConnectorAndThen
MsgBox"Allsearchcriteriawillbecombined."
Else
MsgBox"Criteriawillbetreatedindependently"
EndIf
EndWith
Page 522
ConnectStringPropertyReturnsorsetsaStringthatrepresentstheconnectiontothespecifiedmailmergedatasource.Read/write.
expression.ConnectString
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 523
Example
ThisexamplechecksiftheconnectionstringcontainsthecharactersODSOOutlookanddisplaysamessageaccordingly.
SubVerifyCorrectDataSource()
DimappOfficeAsOfficeDataSourceObject
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
IfInStr(appOffice.ConnectString,"ODSOOutlook")>0Then
MsgBox"YourOutlookaddressbookisusedasthedatasource."
Else
MsgBox"YourOutlookaddressbookisnotusedasthedatasource."
EndIf
EndSub
Page 525
ContextPropertyReturnsorsetsastringthatdetermineswhereacommandbarwillbesaved.Thestringisdefinedandinterpretedbytheapplication.Read/writeString.
Page 526
Remarks
YoucansettheContextpropertyonlyforcustomcommandbars.Thispropertywillfailiftheapplicationdoesn'trecognizethecontextstring,oriftheapplicationdoesn'tsupportchangingcontextstringsprogrammatically.
Page 527
Example
Thisexampledisplaysamessageboxcontainingthecontextstringforthecommandbarnamed“Custom”.ThisexampleworksinMicrosoftWordandotherapplicationsthatsupporttheContextproperty.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
WithmyBar
.Controls.AddType:=msoControlButton,ID:=2
.Visible=True
EndWith
MsgBox(myBar.Context)
Page 528
ControlsPropertyReturnsaCommandBarControlsobjectthatrepresentsallthecontrolsonacommandbarorpop-upcontrol.Read-only.
Forinformationaboutreturningasinglememberofacollection,seeReturninganObjectfromaCollection.
Page 529
Example
Thisexampleaddsacomboboxcontroltothecommandbarnamed"Custom"andfillsthelistwithtwoitems.Theexamplealsosetsthenumberoflineitems,thewidthofthecombobox,andanemptydefaultforthecombobox.
SetmyControl=CommandBars("Custom").Controls_
.Add(Type:=msoControlComboBox,Before:=1)
WithmyControl
.AddItemText:="FirstItem",Index:=1
.AddItemText:="SecondItem",Index:=2
.DropDownLines=3
.DropDownWidth=75
.ListHeaderCount=0
EndWith
Page 530
CountPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ReturnsorsetsaLongindicatingthenumberofitemsinthespecifiedcollection.Read/writeLongfortheBalloonCheckboxesandBalloonLabelsobjects;read-onlyLongforallotherobjectsintheAppliesTolist.
expression.Count
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 531
Remarks
FortheCommandBarscollection,thecountincludesonlymenubars,toolbars,andshortcutmenus.
ForthePermissionobject,theCountpropertyreturns0(zero)ifpermissionsarenotenabledontheactivedocument.Whenpermissionsareenabled,theCountpropertyalwaysreturnsatleast1,representingthepermissionsofthedocumentauthor.
FortheScriptscollection,thecountreturnedisthenumberofscriptblocksinthespecifieddocument.InMicrosoftWord,Scripts.Countreturnsthetotalnumberofinlineandfloatingscriptanchorscombined.
Page 532
Example
ThisexampleusestheCountpropertytodisplaythenumberofcommandbarsintheCommandBarscollection.
MsgBox"Thereare"&CommandBars.Count&_
"barsintheCommandBarscollection."
ThisexampleusestheCountpropertytodisplaythenumberofcheckboxesintheOfficeAssistantballoon.
WithAssistant.NewBalloon
.CheckBoxes(1).Text="FirstChoice"
.CheckBoxes(2).Text="SecondChoice"
.Text="Youhavethefollowing"_
&.CheckBoxes.Count&"choices."
.Show
EndWith
Thisexampledisplaysthenumberofcustomdocumentpropertiesintheactivedocument.
MsgBox("Thereare"&_
ActiveDocument.CustomDocumentProperties.Count&_
"customdocumentpropertiesinthe"&_
"activedocument.")
Page 533
CreatedByPropertyReturnsthefriendlynameofthememberwhocreatedthesharedworkspaceobject.Read-onlyString.
expression.CreatedBy
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 534
Remarks
TheCreatedBypropertyreturnsthefriendlynamestoredintheNamepropertyoftheDWSMemberobject.
TheSharedWorkspaceFolderandSharedWorkspaceMemberobjectsdonothaveaCreatedByproperty.
Page 535
Example
Thefollowingexamplelistsfilesinthesharedworkspacethatwerecreatedbyusersotherthanthecreatoroftheworkspace.
DimswsFileAsOffice.SharedWorkspaceFile
DimswsOwnerAsOffice.SharedWorkspaceMember
DimstrMemberFilesAsString
SetswsOwner=ActiveWorkbook.SharedWorkspace.Members(1)
ForEachswsFileInActiveWorkbook.SharedWorkspace.Files
IfswsFile.CreatedBy<>swsOwner.NameThen
strMemberFiles=strMemberFiles&swsFile.URL&vbCrLf
EndIf
Next
MsgBox"Thesefileswerecreatedbyotherusers:"&_
vbCrLf&strMemberFiles,_
vbInformation+vbOKOnly,"FilesCreatedbyOtherUsers"
SetswsOwner=Nothing
SetswsFile=Nothing
Page 536
CreatedDatePropertyReturnsthedateandtimewhenthesharedworkspaceobjectwascreated.Read-onlyVariant.
expression.CreatedDate
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 537
Remarks
TheSharedWorkspaceFolderandSharedWorkspaceMemberobjectsdonothaveaCreatedDateproperty.
Page 538
Example
Thefollowingexamplereturnsalistofsharedworkspacefileswhosedateandtimecreatedisearlierthantoday.
DimswsFileAsOffice.SharedWorkspaceFile
DimdtmMidnightAsDate
DimdtmFileDateAsDate
DimstrOlderFilesAsString
dtmMidnight=CDate(FormatDateTime(Now,vbShortDate)&"12:00:00am")
ForEachswsFileInActiveWorkbook.SharedWorkspace.Files
dtmFileDate=swsFile.CreatedDate
IfdtmFileDate<dtmMidnightThen
strOlderFiles=strOlderFiles&swsFile.URL&vbCrLf
EndIf
Next
MsgBox"Filesolderthantoday:"&vbCrLf&strOlderFiles,_
vbInformation+vbOKOnly,"OlderFiles"
SetswsFile=Nothing
Page 539
CreatorPropertyReturnsa32-bitintegerthatindicatestheapplicationinwhichthespecifiedobjectwascreated.Forexample,iftheobjectwascreatedinMicrosoftWord,thispropertyreturns1297307460,whichrepresentsthestring"MSWD";inMicrosoftExcel,thispropertyreturns1480803660.ThisvaluecanalsoberepresentedbytheconstantwdCreatorCodeinWord,orxlCreatorCodeinExcel.Read-onlyLong.
expression.Creator
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 540
Remarks
TheCreatorpropertywasprimarilydesignedtobeusedontheMacintosh,whereeachapplicationhasafour-charactercreatorcode.Forexample,MicrosoftWordhasthecreatorcodeMSWD.Foradditionalinformationaboutthisproperty,consultthelanguagereferenceHelpincludedwithMicrosoftOfficeMacintoshEdition.
TheCreatorpropertyalwaysreturnsthenumericidentifierfortheactiveapplication,justastheApplicationpropertyalwaysreturnsthenameoftheactiveapplicatininstringform.UsedtheCreatedBypropertyoftheSharedWorkspaceFile,SharedWorkspaceFolder,SharedWorkspaceLink,andSharedWorkspaceTaskobjectstoreturnthenameoftheindividualwhocreatedthoseobjects.UsedocumentpropertiestoreturninformationabouttheauthorsofOfficedocuments.
Page 541
Example
ThisexampledisplaysamessageaboutthecreatorofmyObject.
SetmyObject=ActiveDocument
IfmyObject.Creator=wdCreatorCodeThen
MsgBox"ThisisaMicrosoftWordobject"
Else
MsgBox"ThisisnotaMicrosoftWordobject"
EndIf
Page 542
DataSourcePropertyReturnsorsetsaStringthatrepresentsthenameoftheattacheddatasource.Read/write.
expression.DataSource
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 543
Example
Thefollowingexamplesetsthenameofthedatasourceifthenameisblank.
SubSetAndReturnDataSourceName()
DimappOfficeAsOfficeDataSourceObject
SetappOffice=Application.OfficeDataSourceObject
WithappOffice
.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
If.DataSource=""Then
.DataSource="Northwind"
MsgBox.DataSource
EndIf
EndWith
EndSub
Page 545
DescriptionPropertyDescriptionpropertyasitappliestotheCOMAddInobject.
ReturnsorsetsadescriptiveStringvalueforthespecifiedCOMAddinobject.Read/write.
expression.Description
expressionRequired.AnexpressionthatreturnsaCOMAddinobject.
DescriptionpropertyasitappliestotheFileDialogFilterobject.
ReturnsthedescriptionofeachFilterobjectasaStringvalue.Thedescriptionisthetextthatisdisplayedinthefiledialogbox.Read-only.
expression.Description
expressionRequired.AnexpressionthatreturnsaFileDialogFilterobject.
DescriptionpropertyasitappliestotheSharedWorkspaceLinkandSharedWorkspaceTaskobjects.
ReturnsorsetsadescriptiveStringvalueforthespecifiedSharedWorkspaceLinkorSharedWorkspaceTaskobject.Read/write.
expression.Description
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceLinkorSharedWorkspaceTaskobject.
Page 546
Remarks
TheDescriptionpropertyisoptionalwhenanewsharedworkspacelinkortaskiscreated,andmaybeempty.
Page 547
Example
AsitappliestotheCOMAddInobject.
ThefollowingexampledisplaysthedescriptiontextoftheMicrosoftAccessibilityCOMadd-infordrawing.
MsgBox"Thedescriptionofthis"&_
"COMAddInis"""&Application.COMAddIns._
Item("msodraa9.ShapeSelect")._
Description&"""
AsitappliestotheFileDialogFilterobject.
ThefollowingexampleiteratesthroughthedefaultfiltersoftheSaveAsdialogboxanddisplaysthedescriptionofeachfilterthatincludesaMicrosoftExcelfile.TheExtensionspropertyisusedtofindtheappropriatefilterobjects.
SubMain()
'DeclareavariableasaFileDialogFilterscollection.
DimfdfsAsFileDialogFilters
'DeclareavariableasaFileDialogFilterobject.
DimfdfAsFileDialogFilter
'SettheFileDialogFilterscollectionvariableto
'theFileDialogFilterscollectionoftheSaveAsdialogbox.
Setfdfs=Application.FileDialog(msoFileDialogSaveAs).Filters
'Iteratethroughthedescriptionandextensionsofeach
'defaultfilterintheSaveAsdialogbox.
ForEachfdfInfdfs
'Displaythedescriptionoffiltersthatinclude
'MicrosoftExcelfiles.
IfInStr(1,fdf.Extensions,"xls",vbTextCompare)>0Then
MsgBox"Filterdescription:"&fdf.Description
EndIf
Nextfdf
EndSub
Page 550
DescriptionTextPropertyReturnsorsetsthedescriptionforacommandbarcontrol.Thedescriptionisnotdisplayedtotheuser,butitcanbeusefulfordocumentingthebehaviorofthecontrolforotherdevelopers.Read/writeString.
Page 551
Remarks
ThispropertyisusedforBalloonHelpontheMacintosh.
Page 552
Example
Thisexampleaddsacontroltoacustomcommandbar,includingadescriptionofthecontrol'sbehavior.
SetmyBar=CommandBars.Add("Custom",msoBarTop,,True)
myBar.Visible=True
SetmyControl=myBar.Controls_
.Add(Type:=msoControlButton,ID:=_
CommandBars("Standard").Controls("Paste").ID)
WithmyControl
.DescriptionText="PastesthecontentsoftheClipboard"
.Caption="Paste"
EndWith
Page 554
DialogTypePropertyReturnsanMsoFileDialogTypeconstantrepresentingthetypeoffiledialogboxthattheFileDialogobjectissettodisplay.Read-only.
MsoFileDialogTypecanbeoneoftheseMsoFileDialogTypeconstants.msoFileDialogFilePickermsoFileDialogFolderPickermsoFileDialogOpenmsoFileDialogSaveAs
expression.DialogType
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 555
Example
ThefollowingexampletakesaFileDialogobjectofanunknowntypeandrunstheExecutemethodifitisaSaveAsdialogboxoranOpendialogbox.
SubDisplayAndExecuteFileDialog(ByReffdAsFileDialog)
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'Iftheuserpressestheactionbutton...
If.Show=-1Then
'UsetheDialogTypepropertytodeterminewhetherto
'usetheExecutemethod.
SelectCase.DialogType
CasemsoFileDialogOpen,msoFileDialogSaveAs:.Execute
'Donothingotherwise.
CaseElse
EndSelect
'IftheuserpressesCancel...
Else
EndIf
EndWith
EndSub
Page 556
DisableAskAQuestionDropdownPropertyTrueiftheAnswerWizarddropdownmenuisenabled.Read/writeBoolean.
expression.DisableAskAQuestionDropdown
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 557
Example
ThefollowingexampletogglestheDisableAskAQuestionDropdownproperty.
SubToggleQuestionDropdown()
WithApplication.CommandBars
If.DisableAskAQuestionDropdown=TrueThen
.DisableAskAQuestionDropdown=False
Else
.DisableAskAQuestionDropdown=True
EndIf
EndWith
EndSub
Page 558
DisableCustomizePropertyTrueiftoolbarcustomizationisdisabled.Read/writeBoolean.
expression.DisableCustomize
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 559
Example
ThefollowingexampletogglestheDisableCustomizeproperty.
SubToggleCustomize()
WithApplication.CommandBars
If.DisableCustomize=TrueThen
.DisableCustomize=False
Else
.DisableCustomize=True
EndIf
EndWith
EndSub
Page 560
DisplayFontsPropertyTrueifthefontnamesintheFontboxaredisplayedintheiractualfonts.Read/writeBoolean.
Page 561
Example
ThisexamplesetsthreeoptionsforallcommandbarsinMicrosoftOffice,includingcustomcommandbarsandthecontrolsonthem.
WithCommandBars
.LargeButtons=True
.DisplayFonts=True
.AdaptiveMenus=True
EndWith
Page 563
DisplayKeysInTooltipsPropertyTrueifshortcutkeysaredisplayedintheToolTipsforeachcommandbarcontrol.Read/writeBoolean.
Page 564
Remarks
TodisplayshortcutkeysinToolTips,youmustalsosettheDisplayTooltipspropertytoTrue.
Page 565
Example
ThisexamplesetsoptionsforallcommandbarsinMicrosoftOffice.
WithCommandBars
.LargeButtons=True
.DisplayTooltips=True
.DisplayKeysInTooltips=True
.MenuAnimationStyle=msoMenuAnimationUnfold
EndWith
Page 567
DisplayTooltipsPropertyTrueifScreenTipsaredisplayedwhenevertheuserpositionsthepointerovercommandbarcontrols.Read/writeBoolean.
Page 568
Remarks
SettingtheDisplayTooltipspropertyinacontainerapplicationimmediatelyaffectseverycommandbarineveryrunningMicrosoftOfficeapplication,andineveryOfficeapplicationopenedafterthepropertyisset.
Page 569
Example
ThisexampledisplayslargecontrolsandToolTipsonallcommandbars.
SetallBars=CommandBars
allBars.LargeButtons=True
allBars.DisplayTooltips=True
Page 570
DocumentAuthorPropertyReturnsorsetsthenameinemailformoftheauthoroftheactivedocument.Read/writeString.
expression.DocumentAuthor
expressionRequired.AnexpressionthatreturnsaPermissionobject.
Page 571
Remarks
TheDocumentAuthorpropertyreturnsorsetstheauthoroftheactivedocument.Theauthoralwayshasnon-expiringownerrightstothedocument,whetherownerpermissionisgrantedexplicitly(throughaUserPermissionobject)ornot.
TheDocumentAuthorpropertycanonlybechangedtoadifferentaccountthathasbeencertifiedthroughthepermissionsuserinterfacetoopenrestrictedcontentonthelocalmachine.Inmostcases,userswhohaveasingleWindowsaccountcanonlychoosebetweentheirWindowsandtheirPassportidentities.
Iftheuser'sMicrosoftWindowsandPassportidentitiesusethesameemailaddress,thenusetheformatpassport:someone@example.comtospecifythePassportidentityastheDocumentAuthorproperty.
Page 572
Example
Thefollowingexampledisplaysinformationaboutthepermissionssettingsoftheactivedocument,includingthedocumentauthor.
DimirmPermissionAsOffice.Permission
DimstrIRMInfoAsString
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
strIRMInfo="Permissionsareenabledonthisdocument."&vbCrLf
strIRMInfo=strIRMInfo&"Viewintrustedbrowser:"&_
irmPermission.EnableTrustedBrowser&vbCrLf&_
"Documentauthor:"&irmPermission.DocumentAuthor&vbCrLf&_
"Userswithrights:"&irmPermission.Count&vbCrLf&_
"Cachelicenseslocally:"&irmPermission.StoreLicenses&vbCrLf&_
"RequestpermissionURL:"&irmPermission.RequestPermissionURL&vbCrLf
IfirmPermission.PermissionFromPolicyThen
strIRMInfo=strIRMInfo&"Permissionsappliedfrompolicy:"&vbCrLf&_
"Policyname:"&irmPermission.PolicyName&vbCrLf&_
"Policydescription:"&irmPermission.PolicyDescription
Else
strIRMInfo=strIRMInfo&"Defaultpermissionsapplied."
EndIf
Else
strIRMInfo="PermissionsareNOTenabledonthisdocument."
EndIf
MsgBoxstrIRMInfo,vbInformation+vbOKOnly,"IRMInformation"
SetirmPermission=Nothing
Page 573
DomainNamePropertyReturnsthedomainandusernameofthespecifiedSharedWorkspaceMemberintheformatdomain\user.Read-onlyString.
expression.DomainName
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceMemberobject.
Page 574
Example
ThefollowingexampleextractsthedomainnamefromtheDomainNamepropertyofeachsharedworkspacememberandlistsmemberswhobelongtothe"MyCompany"domain.
DimswsMemberAsOffice.SharedWorkspaceMember
DimstrDomainAsString
DimstrMemberListAsString
ForEachswsMemberInActiveWorkbook.SharedWorkspace.Members
strDomain=UCase(Left(swsMember.DomainName,_
InStr(swsMember.DomainName,"\")-1))
IfstrDomain="MYCOMPANY"Then
strMemberList=strMemberList&swsMember.Name&vbCrLf
EndIf
Next
MsgBoxstrMemberList,vbInformation+vbOKOnly,_
"MembersintheMYCOMPANYDomain"
SetswsMember=Nothing
Page 576
DropDownLinesPropertyReturnsorsetsthenumberoflinesinacommandbarcomboboxcontrol.Thecomboboxcontrolmustbeacustomcontrolanditmustbeadrop-downlistboxoracombobox.Read/writeLong.
NoteAnerroroccursifyouattempttosetthispropertyforacomboboxcontrolthat'saneditboxorabuilt-incomboboxcontrol.
Page 577
Remarks
Ifthispropertyissetto0(zero),thenumberoflinesinthecontrolwillbebasedonthenumberofitemsinthelist.
Page 578
Example
Thisexampleaddsacomboboxcontrolcontainingtwoitemstothecommandbarnamed"Custom".Theexamplealsosetsthenumberoflineitems,thewidthofthecombobox,andanemptydefaultforthecombobox.
SetmyBar=CommandBars("Custom")
SetmyControl=myBar.Controls.Add(Type:=msoControlComboBox,Id:=1)
WithmyControl
.AddItemText:="FirstItem",Index:=1
.AddItem"SecondItem",2
.DropDownLines=3
.DropDownWidth=75
.ListHeaderCount=0
EndWith
Page 580
DropDownWidthPropertyReturnsorsetsthewidth(inpixels)ofthelistforthespecifiedcommandbarcomboboxcontrol.Read/writeLong.
NoteAnerroroccursifyouattempttosetthispropertyforabuilt-incontrol.
Page 581
Remarks
Ifthispropertyissetto-1,thewidthofthelistisbasedonthelengthofthelongestiteminthecomboboxlist.Ifthispropertyissetto0,thewidthofthelistisbasedonthewidthofthecontrol.
Page 582
Example
Thisexampleaddsacomboboxcontrolcontainingtwoitemstothecommandbarnamed"Custom".Theexamplealsosetsthenumberoflineitems,thewidthofthecombobox,andanemptydefaultforthecombobox.
SetmyBar=CommandBars("Custom")
SetmyControl=myBar.Controls.Add(Type:=msoControlComboBox,Id:=1)
WithmyControl
.AddItem"FirstItem",1
.AddItem"SecondItem",2
.DropDownLines=3
.DropDownWidth=75
.ListHeaderCount=0
EndWith
Page 583
DueDatePropertyReturnsorsetstheoptionalduedateandtimeofaSharedWorkspaceTaskobject.Read/writeVariant.
expression.DueDate()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceTaskobject.
Page 584
Example
ThefollowingexamplesetstheDueDateofalltasksinasharedworkspaceto12:00noononDecember31,2005anduploadsthesechangestotheserverusingtheSavemethod.
DimswsTaskAsOffice.SharedWorkspaceTask
ConstdtmNewDueDateAsDate=#12/31/200512:00:00PM#
ForEachswsTaskInActiveWorkbook.SharedWorkspace.Tasks
swsTask.DueDate=dtmNewDueDate
swsTask.Save
Next
SetswsTask=Nothing
Page 585
EmailPropertyReturnstheemailnameofthespecifiedSharedWorkspaceMemberintheformatuser@domain.com.Read-onlyString.
expression.Email
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceMemberobject.
Page 586
Example
ThefollowingexampleextractstheemaildomainnamefromtheEmailpropertyofeachsharedworkspacememberandlistsmemberswhohaveemailaddressesatthe"mycompany.com"domain.
DimswsMemberAsOffice.SharedWorkspaceMember
DimstrEmailDomainAsString
DimstrMemberListAsString
ForEachswsMemberInActiveWorkbook.SharedWorkspace.Members
strEmailDomain=LCase(Right(swsMember.Email,_
Len(swsMember.Email)-InStr(swsMember.Email,"@")))
IfstrEmailDomain="mycompany.com"Then
strMemberList=strMemberList&swsMember.Email&vbCrLf
EndIf
Next
MsgBoxstrMemberList,vbInformation+vbOKOnly,_
"Memberswithmycompany.comEmail"
SetswsMember=Nothing
Page 588
EnabledPropertyEnabledpropertyasitappliestotheCommandBar,
CommandBarButton,CommandBarComboBox,andCommandBarControlobjects.
Trueifthespecifiedcommandbarorcommandbarcontrolisenabled.Read/writeBoolean.
Page 589
Remarks
Forcommandbars,settingthispropertytoTruecausesthenameofthecommandbartoappearinthelistofavailablecommandbars.
Forbuilt-incontrols,ifyousettheEnabledpropertytoTrue,theapplicationdeterminesitsstate,butsettingittoFalsewillforceittobedisabled.
EnabledpropertyasitappliestothePermissionobject.
ReturnsorsetsaBooleanvaluethatindicateswhetherpermissionsareenabledontheactivedocument.Read/writeBoolean.
expression.Enabled
expressionRequired.AnexpressionthatreturnsaPermissionobject.
Page 590
Remarks
UsetheEnabledpropertytodeterminewhetherpermissionsarerestrictedontheactivedocument,andtoenableordisablepermissions.SetEnabledtoFalsetodisablepermissionsandtoremoveallusers,otherthanthedocumentauthor,andtheirpermissions.
Whenpermissionsaredisabled,theCountpropertyofthePermissionobjectreturns0(zero);however,whenpermissionsarere-enabled,thepermissionsofthedocumentauthorremainintact.
Page 591
Example
AsitappliestotheCommandBar,CommandBarButton,CommandBarComboBox,andCommandBarControlobjects.
Thisexampleadjuststhecommandbarsaccordingtotheuserlevelspecifiedbyuser.Ifuseris"Level1,"thecommandbarnamed"VBCustomBar"isdisplayed.Ifuserisanyothervalue,thebuilt-inVisualBasiccommandbarisresettoitsdefaultstateandthecommandbarnamed"VBCustomBar"isdisabled.
SetmyBar=CommandBars_
.Add(Name:="VBCustomBar",Position:=msoBarTop,_
Temporary:=True)
WithmyBar
.Controls.AddType:=msoControlButton,ID:=2
.Visible=True
EndWith
Ifuser="Level1"Then
myBar.Visible=True
Else
CommandBars("VisualBasic").Reset
myBar.Enabled=False
EndIf
Thisexampleaddstwocommandbarbuttonstothecommandbarnamed“Custom”.Thefirstcontrolisdisabled;thesecondcontrolisenabledbydefault.
SetmyBar=CommandBars("Custom")
WithmyBar
.Controls.AddType:=msoControlButton,Id:=3
.Controls(1).Enabled=False
.Controls.AddType:=msoControlButton,Id:=3
EndWith
myBar.Visible=True
AsitappliestothePermissionobject.
ThefollowingexamplecheckstheEnabledpropertytodeterminewhetherpermissionsarerestrictedontheactivedocument.
Page 592
DimirmPermissionAsOffice.Permission
SetirmPermission=ActiveWorkbook.Permission
SelectCaseirmPermission.Enabled
CaseTrue
MsgBox"Permissionsarerestrictedonthisdocument."&vbCrLf&_
"Thereare"&irmPermission.Count&"userswithrights.",_
vbInformation+vbOKOnly,"IRMInformation"
CaseFalse
MsgBox"PermissionsareNOTrestrictedonthisdocument.",_
vbInformation+vbOKOnly,"IRMInformation"
EndSelect
SetirmPermission=Nothing
Page 593
EnableTrustedBrowserPropertyReturnsorsetstheoptionthatallowsausertoviewadocumentwithrestrictedpermissionsinawebbrowseriftheuserdoesnothavetheappropriateclientapplicationinstalled.Read/writeBoolean.DefaultisFalse.
expression.EnableTrustedBrowser
expressionRequired.AnexpressionthatreturnsaPermissionobject.
Page 594
Remarks
TheEnableTrustedBrowserproperty,whenTrue,allowsauserwhotriestoopenaOfficeWord2003documentwithrestrictedpermissions,forexample,butwhodoesnothavetheOfficeWord2003applicationinstalled,toviewthedocumentinMicrosoftInternetExploreroranotherbrowserthatsupportsthisfunctionality.ThispropertycorrespondstothecheckboxAllowuserswithearlierversionsofOfficetoreadwithbrowserssupportingInformationRightsManagement.(Increasesfilesize.)intheuserinterface.
Page 595
Example
Thefollowingexamplereportswhethertheactivedocumenthasrestrictedpermissionsand,ifso,whethertheEnableTrustedBrowserpropertyisalsoenabled.
DimirmPermissionAsOffice.Permission
SetirmPermission=ActiveWorkbook.Permission
SelectCaseirmPermission.Enabled
CaseTrue
SelectCaseirmPermission.EnableTrustedBrowser
CaseTrue
MsgBox"Permissionsarerestrictedonthisdocument."&_
vbCrLf&"Viewingintrustedbrowserisalsoenabled.",_
vbInformation+vbOKOnly,"IRMInformation"
CaseFalse
MsgBox"Permissionsarerestrictedonthisdocument."&_
vbCrLf&"However,viewingintrustedbrowserisdisabled.",_
vbInformation+vbOKOnly,"IRMInformation"
EndSelect
CaseFalse
MsgBox"PermissionsareNOTrestrictedonthisdocument.",_
vbInformation+vbOKOnly,"IRMInformation"
EndSelect
SetirmPermission=Nothing
Page 597
ErrorTypePropertyReturnsaconstantwhichindicatesthetypeofthemostrecentdocumentsynchronizationerror.Read-onlyMsoSyncErrorType.
MsoSyncErrorTypecanbeoneofthefollowingmsoSyncErrorTypeconstants.msoSyncErrorNone(0)msoSyncErrorUnauthorizedUser(1)msoSyncErrorCouldNotConnect(2)msoSyncErrorOutOfSpace(3)msoSyncErrorFileNotFound(4)msoSyncErrorFileTooLarge(5)msoSyncErrorFileInUse(6)msoSyncErrorVirusUpload(7)msoSyncErrorVirusDownload(8)msoSyncErrorUnknownUpload(9)msoSyncErrorUnknownDownload(10)msoSyncErrorCouldNotOpen(11)msoSyncErrorCouldNotUpdate(12)msoSyncErrorCouldNotCompare(13)msoSyncErrorCouldNotResolve(14)msoSyncErrorNoNetwork(15)msoSyncErrorUnknown(16)
expression.ErrorType()
expressionRequired.AnexpressionthatreturnsaSyncobject.
Page 598
Remarks
UsetheErrorTypepropertytodeterminethetypeofthemostrecentdocumentsynchronizationerror.
Notalldocumentsynchronizationproblemsraisetrappablerun-timeerrors.AfterperforminganoperationusingtheSyncobject,it'sagoodideatochecktheStatusproperty;iftheStatuspropertyismsoSyncStatusError,checktheErrorTypepropertyforadditionalinformationonthetypeoferrorthathasoccurred.
Page 599
Example
ThefollowingexamplecheckstheStatusproperty,thenusestheErrorTypepropertytodisplaythetypeofsyncerrorthathasoccurred.
DimobjSyncAsOffice.Sync
DimstrErrorAsString
SetobjSync=ActiveDocument.Sync
IfobjSync.Status=msoSyncStatusErrorThen
strError="Asyncerrorhasoccurred."&vbCrLf&_
"Errortype:"&objSync.ErrorType
Else
strError="Nosyncerrorhasoccurred."
EndIf
MsgBoxstrError,vbInformation+vbOKOnly,"ErrorInformation"
SetobjSync=Nothing
Page 600
ExpirationDatePropertyReturnsorsetstheoptionalexpirationdateofthepermissionsontheactivedocumentassignedtotheuserassociatedwiththespecifiedUserPermissionobject.Read/writeVariant.
expression.ExpirationDate
expressionRequired.AnexpressionthatreturnsaUserPermissionobject.
Page 601
Remarks
TheUserPermissionobjectassociatesasetofpermissionsontheactivedocumentwithasingleuserandanoptionalexpirationdate.TheExpirationDatepropertyreturnsorsetstheoptionalexpirationdateofthespecifiedUserPermissionobjectusingthelocaltimezone.
Page 602
Example
Thefollowingexampleextendstheexpirationdateoftheseconduser'spermissionsontheactivedocumentbyanadditionalsixmonths.
DimirmPermissionAsOffice.Permission
DimirmUserPermAsOffice.UserPermission
DimdtmOldDateAsDate,dtmNewDateAsDate
SetirmPermission=ActiveWorkbook.Permission
SetirmUserPerm=irmPermission.Item(2)
dtmOldDate=irmUserPerm.ExpirationDate
dtmNewDate=DateAdd("m",6,dtmOldDate)
irmUserPerm.ExpirationDate=dtmNewDate
MsgBox"Permissionsexpirationfor"&irmUserPerm.UserId&vbCrLf&_
"extendedfrom"&dtmOldDate&"to"&dtmNewDate,_
vbInformation+vbOKOnly,"IRMInformation"
SetirmUserPerm=Nothing
SetirmPermission=Nothing
Page 603
ExpireDatePropertyReturnsaVariantrepresentingthedateonwhichthedigitalsignaturethatcorrespondstotheSignatureobjectwillexpire.Read-only.
expression.ExpireDate
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 604
Example
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandcallthisfunction.Thefunctionwilltesttomakesurethatthedigitalsignaturethattheuserselectswillnotexpireinlessthan12months.Ifitwillexpire,thecertificateisn'tattached.
FunctionAddSignature()AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
'TesttomakesurethatthenewSignatureobject
'doesn'texpiretoosoon.Thisexpressioncalculates
'thenumberofmonthsuntiltheSignatureobjectexpires.
IfDateDiff("m",sig.SignDate,sig.ExpireDate)<12Then
MsgBox"ThisCertificatewillexpireinlessthan1year."&vbCrLf&_
"Pleaseuseanewercertificate."
AddSignature=False
sig.Delete
Else
AddSignature=True
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 606
ExtendedPropertySetsorreturnsattributesaddedtothe<SCRIPT>tag,withtheexceptionoftheLANGUAGEandIDattributes.Read/writeString.
Page 607
Remarks
Attributesareseparatedbyspaces,thesameasinHTML.YoucannotpasstheLANGUAGEattributeortheIDattributebyusingtheExtendedproperty.
TheMicrosoftOfficehostapplicationdoesn’tprovideanymeansofcheckingthesyntaxofpassedattributes.
IfyoupasstheLANGUAGEattributeintheExtendedproperty,the<SCRIPT>tagreceivestwolanguagesettings,whichcausesaconflict.
IfyoupassanIDattributeintheExtendedpropertyandnoIDhasbeensetthrougheithertheIDparameteroftheAddmethodortheIdpropertyoftheScriptobject,theIDisexportedcorrectly.
Page 608
Example
ThisexamplecheckstheExtendedpropertytoensurethatnoadditionalattributeshavebeenaddedtothefirstscriptinworksheetoneintheactiveworkbook.
IfActiveWorkbook.Worksheets(1).Scripts(1).Extended_
<>""Then
MsgBox"Thisscriptcontainsextendedattributes."
EndIf
Page 609
ExtensionsPropertyReturnsaStringvaluecontainingtheextensionsthatdeterminewhichfilesaredisplayedinafiledialogboxforeachFilterobject.Read-only.
expression.Extensions
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 610
Example
ThefollowingexampleiteratesthroughthedefaultfiltersoftheSaveAsdialogboxanddisplaysthedescriptionofeachfilterthatincludesaMicrosoftExcelfile.TheExtensionspropertyisusedtofindtheappropriatefilterobjects.
SubMain()
'DeclareavariableasaFileDialogFilterscollection.
DimfdfsAsFileDialogFilters
'DeclareavariableasaFileDialogFilterobject.
DimfdfAsFileDialogFilter
'SettheFileDialogFilterscollectionvariableto
'theFileDialogFilterscollectionoftheSaveAsdialogbox.
Setfdfs=Application.FileDialog(msoFileDialogSaveAs).Filters
'Iteratethroughthedescriptionandextensionsofeach
'defaultfilterintheSaveAsdialogbox.
ForEachfdfInfdfs
'Displaythedescriptionoffiltersthatinclude
'MicrosoftExcelfiles.
IfInStr(1,fdf.Extensions,"xls",vbTextCompare)>0Then
MsgBox"Descriptionoffilter:"&fdf.Description
EndIf
Nextfdf
EndSub
Page 612
FaceIdPropertyReturnsorsetstheIdnumberforthefaceofacommandbarbuttoncontrol.Read/writeLong.
Page 613
Remarks
TheFaceIdpropertydictatesthelook,notthefunction,ofacommandbarbutton.TheIdpropertyoftheCommandBarControlobjectdeterminesthefunctionofthebutton.
ThevalueoftheFaceIdpropertyforacommandbarbuttonwithacustomfaceis0(zero).
Page 614
Example
Thisexampleaddsacommandbarbuttontoacustomcommandbar.ClickingthisbuttonisequivalenttoclickingtheOpencommandontheFilemenubecausetheIDnumberis23,yetthebuttonhasthesamebuttonfaceasthebuilt-inChartingbutton.
SetnewBar=CommandBars.Add(Name:="Custom2",_
Position:=msoBarTop,Temporary:=True)
newBar.Visible=True
Setcon=newBar.Controls.Add(Type:=msoControlButton,Id:=23)
con.FaceId=17
Page 615
FeatureTipsPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantprovidesinformationaboutusingapplicationfeaturesmoreeffectively.Read/writeBoolean.
Page 616
Remarks
TheFeatureTipspropertycorrespondstotheUsingfeaturesmoreeffectivelycheckboxontheOptionstabintheAssistantdialogbox.
Page 617
Example
ThisexampleallowstheOfficeAssistanttoprovideinformationaboutusingapplicationfeaturesmoreeffectively.
Assistant.FeatureTips=True
Page 618
FileNamePropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
Assistantobject:ReturnsorsetsthepathandfilenamefortheactiveOfficeAssistant.Read/writeString.
FileSearchobject:Returnsorsetsthenameofthefiletolookforduringafilesearch.Thenameofthefilemayincludethe*(asterisk)or?(questionmark)wildcards.Usethequestionmarkwildcardtomatchanysinglecharacter.Forexample,typegr?ytomatchboth"gray"and"grey."Usetheasteriskwildcardtomatchanynumberofcharacters.Forexample,type*.txttofindallfilesthathavethe.TXTextension.Read/writeString.
expression.FileName
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 619
Example
ThisexamplesearchesforallfileslocatedintheMyDocumentsfolderthatbeginwith"cmd"andhaveafilenameextension.Theexampledisplaysthenameandlocationofeachfoundfile.
Setfs=Application.FileSearch
Withfs
.LookIn="C:\MyDocuments"
.FileName="cmd*.*"
If.Execute>0Then
MsgBox"Therewere"&.FoundFiles.Count&_
"file(s)found."
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
Nexti
Else
MsgBox"Therewerenofilesfound."
EndIf
EndWith
Page 621
FilesPropertyFilespropertyasitappliestotheAnswerWizardobject.
ReturnsanAnswerWizardFilescollectionthatrepresentsthelistoffilesavailabletothecurrentAnswerWizard.Read-only.
Forinformationaboutreturningasinglememberofacollection,seeReturninganObjectfromaCollection.
FilespropertyasitappliestotheSharedWorkspaceobject.
ReturnsaSharedWorkspaceFilescollectionthatrepresentsthelistoffilesstoredinthedocumentlibraryassociatedwiththecurrentsharedworkspace.Read-only.
Page 622
Example
AsitappliestotheAnswerWizardobject.
ThisexampleresetsthefilelistforthecurrentAnswerWizardandthendisplaysboththefilecountandthefilenamesinamessagebox.
DimcustomAnswerWizardAsAnswerWizard
DimstrFileListAsString
DimintCounterAsInteger
DimintNumFilesAsInteger
SetcustomAnswerWizard=Application.AnswerWizard
intCounter=1
customAnswerWizard.ResetFileList
strFileList=""
intNumFiles=customAnswerWizard.Files.Count
ForintCounter=1To(intNumFiles)
strFileList=strFileList&_
customAnswerWizard.Files.Item(intCounter)&Chr(13)
Next
MsgBox"Thereare"&customAnswerWizard.Files.Count&_
"filesavaialblethroughthisAnswerWizard:"&_
Chr(13)&strFileList
AsitappliestotheSharedWorkspaceobject.
Thefollowingexampleliststhefilessavedinthecurrentsharedworkspace.
DimswsFilesAsOffice.SharedWorkspaceFiles
SetswsFiles=ActiveWorkbook.SharedWorkspace.Files
MsgBox"Thereare"&swsFiles.Count&_
"file(s)
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsFiles=Nothing
Page 625
FileTypePropertyReturnsorsetsthetypeoffiletolookforduringafilesearch.Read/write
MsoFileType.
MsoFileTypecanbeoneoftheseMsoFileTypeconstants.msoFileTypeAllFilesmsoFileTypeBindersmsoFileTypeCalendarItemmsoFileTypeContactItemmsoFileTypeCustommsoFileTypeDatabasesmsoFileTypeDataConnectionFilesmsoFileTypeDesignerFilesmsoFileTypeDocumentImagingFilesmsoFileTypeExcelWorkbooksmsoFileTypeJournalItemmsoFileTypeMailItemmsoFileTypeNoteItemmsoFileTypeOfficeFilesmsoFileTypeOutlookItemsmsoFileTypePhotoDrawFilesmsoFileTypePowerPointPresentationsmsoFileTypeProjectFilesmsoFileTypePublisherFilesmsoFileTypeTaskItemmsoFileTypeTemplatesmsoFileTypeVisioFilesmsoFileTypeWebPagesmsoFileTypeWordDocuments
Page 626
expression.FileType
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 627
Remarks
TheconstantmsoFileTypeOfficeFilesincludesallfileswithanyofthefollowingextensions:*.doc,*.xls,*.ppt,*.pps,*.obd,*.mdb,*.mpd,*.dot,*.xlt,*.pot,*.obt,*.htm,or*.html.
Page 628
Example
ThisexamplesearchesforallBinderfileslocatedintheMyDocumentsfolder.Theexampledisplaysamessageboxthatcontainsthenameandlocationofeachfilethat’sfound.
Setfs=Application.FileSearch
Withfs
.LookIn="C:\MyDocuments"
.FileType=msoFileTypeBinders
If.Execute>0Then
MsgBox"Therewere"&.FoundFiles.Count&_
"Binderfile(s)found."
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
Nexti
Else
MsgBox"TherewerenoBinderfilesfound."
EndIf
EndWith
Page 629
FileTypesPropertyReturnsaFileTypescollection.
expression.FileTypes
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 630
Example
ThefollowingexamplesearchesforallHTMLandMicrosoftExcelfilesontheC:\drive.
SubSearchForFiles()
'Declareavariabletoactasagenericcounter.
DimlngCountAsLong
'UseaWith...EndWithblocktoreferencethe
'FileSearchobject.
WithApplication.FileSearch
'Clearalltheparametersoftheprevioussearches.
'Thismethoddoesn'tcleartheLookInpropertyor
'theSearchFolderscollection.
.NewSearch
'SettingtheFileTypepropertyclearsthe
'FileTypescollectionandsetsthefirst
'iteminthecollectiontothefiletype
'definedbytheFileTypeproperty.
.FileType=msoFileTypeWebPages
'AddaseconditemtotheFileTypescollection.
.FileTypes.AddmsoFileTypeExcelWorkbooks
'DisplaythenumberofFileTypesobjectsinthecollection.
MsgBox"Youareabouttosearchfor"&.FileTypes.Count&_
"filetypes."
'SetupthesearchtolookinallsubfoldersontheC:\drive.
.LookIn="C:\"
.SearchSubFolders=True
'Executethesearchandtesttoseeifanyfiles
'werefound.
If.Execute<>0Then
'Displaythenumberoffilesfound.
MsgBox"Filesfound:"&.FoundFiles.Count
'Loopthroughthelistoffoundfilesand
'displaythepathofeachoneinamessagebox.
ForlngCount=1To.FoundFiles.Count
Page 631
IfMsgBox(.FoundFiles.Item(lngCount),vbOKCancel,_
"Foundfiles")=vbCancelThen
'Breakoutoftheloop
lngCount=.FoundFiles.Count
EndIf
NextlngCount
Else
MsgBox"Nofilesfound."
EndIf
EndWith
EndSub
Page 632
FilterIndexPropertyReturnsorsetsaLongindicatingthedefaultfilefilterofafiledialogbox.Thedefaultfilterdetermineswhichtypesoffilesaredisplayedwhenthefiledialogboxisfirstopened.Read/write.
expression.FilterIndex
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 633
Remarks
Ifyoutrytosetthispropertytoanumbergreaterthanthenumberoffilters,thelastavailablefilterwillbeselected.
Page 634
Example
ThefollowingexampledisplaysaFilePickerdialogboxusingtheFileDialogobjectanddisplayseachselectedfileinamessagebox.Thisexamplealsodemonstrateshowtoaddanewfilefilterandhowtomakeitthedefaultfilter.
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'AddafilterthatincludesGIFandJPEGimagesandmakeittheseconditeminthelist.
.Filters.Add"Images","*.gif;*.jpg;*.jpeg",2
'Setstheinitialfilefiltertonumber2.
.FilterIndex=2
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Iftheuserpressestheactionbutton...
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Selecteditem'spath:"&vrtSelectedItem
NextvrtSelectedItem
'IftheuserpressesCancel...
Else
EndIf
EndWith
Page 635
'SettheobjectvariabletoNothing.
Setfd=Nothing
EndSub
Page 636
FiltersPropertyReturnsaFileDialogFilterscollection.
expression.Filters
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 637
Example
ThefollowingexampledisplaysaFilePickerdialogboxusingtheFileDialogobjectanddisplayseachselectedfileinamessagebox.Theexamplealsoaddsanewfilefiltercalled"Images."
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialog.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'AddafilterthatincludesGIFandJPEGimagesandmakeitthefirstiteminthelist.
.Filters.Add"Images","*.gif;*.jpg;*.jpeg",1
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Iftheuserpressestheactionbutton...
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Selecteditem'spath:"&vrtSelectedItem
NextvrtSelectedItem
'IftheuserpressesCancel...
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Setfd=Nothing
Page 639
FixedWidthFontPropertySetsorreturnsthefixed-widthfontsettinginthehostapplication.Read/writeString.
Page 640
Remarks
WhenyousettheFixedWidthFontproperty,thehostapplicationdoesnotcheckthevalueforvalidity.
Page 641
Example
Thisexamplesetsthefixed-widthfontandfixed-widthfontsizefortheEnglish/WesternEuropean/OtherLatinScriptcharactersetintheactiveapplication.
Application.DefaultWebOptions._
Fonts(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)_
.FixedWidthFont="System"
Application.DefaultWebOptions._
Fonts(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)_
.FixedWidthFontSize=12
Page 642
FixedWidthFontSizePropertySetsorreturnsthefixed-widthfontsizesettinginthehostapplication,inpoints.Read/writeSingle.
Page 643
Remarks
WhenyousettheFixedWidthFontSizeproperty,thehostapplicationdoesnotcheckthevalueforvalidity.Ifyouenteraninvalidvalue,suchasanonnumber,thehostapplicationsetsthesizeto0points.Youcanenterhalf-pointsizes;ifyouenterotherfractionalpointsizes,theyareroundedupordowntothenearesthalf-point.
Page 644
Example
Thisexamplesetsthefixed-widthfontandfixed-widthfontsizefortheEnglish/WesternEuropean/OtherLatinScriptcharactersetintheactiveapplication.
Application.DefaultWebOptions._
Fonts(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)_
.FixedWidthFont="System"
Application.DefaultWebOptions._
Fonts(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)_
.FixedWidthFontSize=12
Page 645
FolderNamePropertyReturnsthenameofasubfolderwithinthemaindocumentlibraryfolderofasharedworkspace.Read-onlyString.
expression.FolderName()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceFolderobject.
Page 646
Remarks
TheFolderNamepropertyreturnsthesubfoldernameintheformatparentfolder/subfolder.Forexample,ifthesharedworkspacecontainsafoldernamed"SupportingDocuments",theFolderNamepropertyreturnsSharedDocuments/SupportingDocuments.
Page 647
Example
Thefollowingexampledisplaysthenumberofsubfoldersinthesharedworkspaceandtheirnames.
DimswsFolderAsOffice.SharedWorkspaceFolder
DimstrFolderInfoAsString
strFolderInfo="Thesharedworkspacecontains"&_
ActiveWorkbook.SharedWorkspace.Folders.Count&"folder(s)."&vbCrLf
IfActiveWorkbook.SharedWorkspace.Folders.Count>0Then
ForEachswsFolderInActiveWorkbook.SharedWorkspace.Folders
strFolderInfo=strFolderInfo&swsFolder.FolderName&vbCrLf
Next
EndIf
MsgBoxstrFolderInfo,vbInformation+vbOKOnly,_
"FoldersinSharedWorkspace"
SetswsFolder=Nothing
Page 648
FoldersPropertyReturnsaSharedWorkspaceFolderscollectionthatrepresentsthelistofsubfoldersinthedocumentlibraryassociatedwiththecurrentsharedworkspace.Read-only.
expression.Folders()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 649
Remarks
TheSharedWorkspaceFolderscollectiondoesnotincludetherootdocumentlibraryfolderitself,whichbydefaultisnamed"SharedDocuments".
Page 650
Example
Thefollowingexampleliststhesubfoldersinthecurrentsharedworkspace.
DimswsFoldersAsOffice.SharedWorkspaceFolders
SetswsFolders=ActiveWorkbook.SharedWorkspace.Folders
MsgBox"Thereare"&swsFolders.Count&_
"folder(s)inthecurrentsharedworkspace.",_
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsFolders=Nothing
Page 651
FoundFilesPropertyReturnsaFoundFilesobjectthatcontainsthenamesofallthefilesfoundduringasearch.Read-only.
Page 652
Example
Thisexamplestepsthroughthelistoffilesfoundduringasearchanddisplaysthepathforeachfile.
WithApplication.FileSearch
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
NextI
EndWith
Page 653
GuessHelpPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantballoonpresentsalistofHelptopicsbasedonkeywordstheuserselectsbeforeclickingtheAssistantwindoworpressingF1.Read/writeBoolean.
NoteThispropertyisobsoletebuthasbeenretainedforcompatibilitywithcodewritteninpreviousversionsofMicrosoftOffice.
Page 654
Remarks
TheGuessHelppropertycorrespondstotheGuesshelptopicsoptionunderUsetheOfficeAssistantontheOptionstabintheOfficeAssistantdialogbox.
Page 655
Example
ThisexampleallowstheOfficeAssistanttoguessatHelptopics.
Assistant.GuessHelp=True
Page 656
GuidPropertyReturnsthegloballyuniqueclassidentifier(GUID)forthespecifiedCOMAddInobject.Read-onlyString.
Page 657
Example
ThefollowingexampledisplaystheProgIDandGUIDforCOMadd-inoneinamessagebox.
MsgBox"MyProgIDis"&_
Application.COMAddIns(1).ProgID&_
"andmyGUIDis"&_
Application.COMAddIns(1).Guid
Page 658
HeadingPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ReturnsorsetstheheadingthatappearsintheOfficeAssistantballoon.Read/writeString.
Page 659
Remarks
Youcanspecifyagraphictobedisplayedintheballoonheadingbyusingthefollowingsyntax:{typelocationsizing_factor},wheretypeisbmp(bitmap)orwmf(Windowsmetafile),locationistheresourceIDorthepathandfilename,andsizing_factorspecifiesthewidthofthewmf(omittedforbmp).
Theballoonheadingalsosupportsunderlinedtextandtextthathasoneofthe16systempalettecolorsappliedtoit.Todisplayunderlinedtextinaheading,usethesyntax{ul}or{ul1};use{ul0}toturnunderliningoff.Tochangethecolorofheadingtext,precedethetextstringwiththecharactersequence{cfnumber},wherenumberisoneofthesystemcolornumberslistedinthefollowingtable.
Systemcolornumber Color0 Black1 Darkred2 Darkgreen3 Darkyellow4 Darkblue5 Darkmagenta6 Darkcyan7 Lightgray248 Mediumgray249 Red250 Green251 Yellow252 Blue253 Magenta254 Cyan255 White
Ifyouspecifyanumberotherthanoneoftheprecedingsystemcolornumbers,theheadingtextisblack.
Page 660
Example
Thisexampledisplaysaballoonwithaheading,text,andthreeregionchoices.
WithAssistant.NewBalloon
.Button=msoButtonSetOkCancel
.Heading="RegionalSalesData"
.Text="Selectaregion"
Fori=1To3
.CheckBoxes(i).Text="Region"&i
Next
.Show
EndWith
Page 662
HeightPropertyReturnsorsetstheheightofacommandbarcontrolorcommandbar.Read/writeLong.
expression.Height
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 663
Example
ThisexampleaddsacustomcontroltothecommandbarnamedCustom.Theexamplesetstheheightofthecustomcontroltotwicetheheightofthecommandbarandsetsthecontrol’swidthto50pixels.Noticehowthecommandbarautomaticallyresizesitselftoaccommodatethecontrol.
SetmyBar=CommandBars("Custom")
barHeight=myBar.Height
SetmyControl=myBar.Controls_
.Add(Type:=msoControlButton,_
Id:=CommandBars("Standard").Controls("Save").Id,_
Temporary:=True)
WithmyControl
.Height=barHeight*2
.Width=50
EndWith
myBar.Visible=True
Page 665
HelpContextIdPropertyReturnsorsetstheHelpcontextIdnumberfortheHelptopicattachedtothecommandbarcontrol.Read/writeLong.
Page 666
Remarks
Tousethisproperty,youmustalsosettheHelpFileproperty.HelptopicsrespondtoShift+F1.
Page 667
Example
Thisexampleaddsacustomcommandbarwithacomboboxthattracksstockdata.TheexamplealsospecifiestheHelptopictobedisplayedforthecomboboxwhentheuserpressesSHIFT+F1.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
WithmyBar
.Controls.AddType:=msoControlComboBox,ID:=1
.Visible=True
EndWith
WithCommandBars("Custom").Controls(1)
.AddItem"GetStockQuote",1
.AddItem"ViewChart",2
.AddItem"ViewFundamentals",3
.AddItem"ViewNews",4
.Caption="StockData"
.DescriptionText="ViewDataForStock"
.HelpFile="C:\corphelp\custom.hlp"
.HelpContextID=47
EndWith
Page 669
HelpFilePropertyReturnsorsetsthefilenamefortheHelptopicattachedtothecommandbarcontrol.Read/writeString.
Page 670
Remarks
Tousethisproperty,youmustalsosettheHelpContextIDproperty.HelptopicsrespondtotheuserpressingSHIFT+F1.
Page 671
Example
Thisexampleaddsacustomcommandbarwithacomboboxthattracksstockdata.TheexamplealsospecifiestheHelptopictobedisplayedforthecomboboxwhentheuserpressesSHIFT+F1.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
WithmyBar
.Controls.AddType:=msoControlComboBox,ID:=1
.Visible=True
EndWith
WithCommandBars("Custom").Controls(1)
.AddItem"GetStockQuote",1
.AddItem"ViewChart",2
.AddItem"ViewFundamentals",3
.AddItem"ViewNews",4
.Caption="StockData"
.DescriptionText="ViewDataForStock"
.HelpFile="C:\corphelp\custom.hlp"
.HelpContextID=47
EndWith
Page 672
HighPriorityTipsPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantdisplayshigh-prioritytips.Read/writeBoolean.
Page 673
Remarks
TheHighPriorityTipspropertycorrespondstotheOnlyshowhighprioritytipsoptionunderShowtipsaboutontheOptionstabintheOfficeAssistantdialogbox.
Page 674
Example
ThisexamplesetstheOfficeAssistanttodisplayhigh-prioritytips.
Assistant.HighPriorityTips=True
Page 675
HTMLProjectItemsPropertyReturnstheHTMLProjectItemscollectionthatisincludedinthespecifiedHTMLproject.Read-onlyHTMLProjectItems.
Page 676
Example
ThisexamplereturnsthenumberofitemsintheHTMLProjectItemscollectionintheHTMLprojectintheactiveworkbook.
intCount=ActiveWorkbook.HTMLProject.HTMLProjectItems.Count
Page 678
HyperlinkTypePropertySetsorreturnsthetypeofhyperlinkassociatedwiththespecifiedcommandbarbutton.Read/writeMsoCommandBarButtonHyperlinkType.
MsoCommandBarButtonHyperlinkTypecanbeoneoftheseMsoCommandBarButtonHyperlinkTypeconstants.msoCommandBarButtonHyperlinkInsertPicturemsoCommandBarButtonHyperlinkNonemsoCommandBarButtonHyperlinkOpen
Page 679
Example
ThisexamplecheckstheHyperlinkTypepropertyforthespecifiedcommandbarbuttononthecommandbarnamed"Custom.".IfHyperlinkTypeissettomsoCommandBarButtonHyperlinkNone,theexamplesetsthepropertytomsoCommandBarButtonHyperlinkOpenandsetstheURLtowww.microsoft.com.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
SetmyButton=myBar.Controls.Add(Type:=msoControlButton)
WithmyButton
.FaceId=277
.HyperlinkType=msoCommandBarButtonHyperlinkNone
EndWith
IfmyButton.HyperlinkType<>_
msoCommandBarButtonHyperlinkOpenThen
myButton.HyperlinkType=_
msoCommandBarButtonHyperlinkOpen
myButton.TooltipText="www.microsoft.com"
EndIf
Page 681
IconPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
Returnsorsetsthetypeoficonthatappearsintheupper-leftportionoftheOfficeAssistantballoon.Read/writeMsoIconType.
MsoIconTypecanbeoneoftheseMsoIconTypeconstants.msoIconAlertmsoIconAlertCriticalmsoIconAlertInfomsoIconAlertQuerymsoIconAlertWarningmsoIconNonemsoIconTip
Page 682
Example
Thisexamplecreatesaballoonwithan“Alert”iconthatinstructstheusertoselectaprinter.
WithAssistant.NewBalloon
.Heading="SelectAPrinter"
.Text="Youmustselectaprinterbeforeprinting."
.Icon=msoIconAlert
.CheckBoxes(1).Text="Localprinter"
.CheckBoxes(2).Text="Networkprinter"
.Show
EndWith
Page 684
IdPropertyIdpropertyasitappliestotheCommandBarButton,
CommandBarComboBox,andCommandBarControlobjects.
ReturnstheIDforabuilt-incommandbarcontrol.Read-onlyLong.
expression.Id
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 685
Remarks
Acontrol'sIDdeterminesthebuilt-inactionforthatcontrol.ThevalueoftheIdpropertyforallcustomcontrolsis1.
IdpropertyasitappliestotheScriptobject.
SetsorreturnstheIDofaScriptobject.Read/writeString.
expression.Id
expressionRequired.AnexpressionthatreturnsaScriptobject.
Page 686
Remarks
TheIDreturnedistheIDattributeofthe<SCRIPT>taginHTML.Ifthere’snoIDattributespecifiedinthe<SCRIPT>tag,theIdpropertyreturnsanemptystring.
IdspecifiesanSGMLidentifierusedfornamingelements.Valididentifiersincludeanystringthatbeginswithaletterandiscomposedofalphanumericcharacters;thestringcanalsoincludetheunderscorecharacter(_).
TheIDmustbeuniquewithintheHTMLdocument.
Page 687
Example
AsitappliestotheCommandBarButton,CommandBarComboBox,andCommandBarControlobjects.
Thisexamplechangesthebuttonfaceofthefirstcontrolonthecommandbarnamed"Custom2"ifthebutton'sIDvalueislessthan25.
Setctrl=CommandBars("Custom").Controls(1)
Withctrl
If.Id<25Then
.FaceId=17
.Tag="Changedcontrol"
EndIf
EndWith
Thefollowingexamplechangesthecaptionofeverycontrolonthetoolbarnamed"Standard"tothecurrentvalueoftheIdpropertyforthatcontrol.
ForEachctlInCommandBars("Standard").Controls
ctl.Caption=CStr(ctl.Id)
Nextctl
AsitappliestotheScriptobject.
ThisexamplesetstheIdpropertyofthefirstscriptinworksheetoneoftheactiveworkbooktoanewvalue.
ActiveWorkbook.Worksheets(1).Scripts(1).Id="UpdatedScriptName"
Page 688
IndexPropertyReturnsaLongrepresentingtheindexnumberforanobjectinthecollection.Read-only.
expression.Index
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 689
Remarks
Thepositionofthefirstcommandbarcontrolis1.SeparatorsarenotcountedintheCommandBarControlscollection.
Page 690
Example
Thisexamplesearchesthecommandbarnamed"Custom2"foracontrolwithanIdvalueof23.Ifsuchacontrolisfoundandtheindexnumberofthecontrolisgreaterthan5,thecontrolwillbepositionedasthefirstcontrolonthecommandbar.
SetmyBar=CommandBars("Custom2")
Setctrl1=myBar.FindControl(Id:=23)
Ifctrl1.Index>5Then
ctrl1.Movebefore:=1
EndIf
Page 691
InitialFileNamePropertySetorreturnsaStringrepresentingthepathand/orfilenamethatisinitiallydisplayedinafiledialogbox.Read/write.
expression.InitialFileName
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 692
Remarks
Youcanusethe'*'and'?'wildcardcharacterswhenspecifyingthefilenamebutnotwhenspecifyingthepath.The'*'representsanynumberofconsecutivecharactersandthe'?'representsasinglecharacter.Forexample,.InitialFileName="c:\c*s.txt"willreturnboth"charts.txt"and"checkregister.txt."
Ifyouspecifyapathandnofilename,thenallfilesthatareallowedbythefilefilterwillappearinthedialogbox.
Ifyouspecifyafilethatexistsintheinitialfolder,thenonlythatfilewillappearinthedialogbox.
Ifyouspecifyafilenamethatdoesn'texistintheinitialfolder,thenthedialogboxwillcontainnofiles.ThetypeoffilethatyouspecifyintheInitialFileNamepropertywilloverridethefilefiltersettings.
Ifyouspecifyaninvalidpath,thelast-usedpathisused.Amessagewillwarnuserswhenaninvalidpathisused.
Settingthispropertytoastringlongerthan256characterswillcausearun-timeerror.
Page 693
Example
ThefollowingexampledisplaysaFilePickerdialogboxusingtheFileDialogobjectanddisplayseachselectedfileinamessagebox.
SubMain()
'DeclareavariableasaFileDialogobject
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'SettheinitialpathtotheC:\drive.
.InitialFileName="C:\"
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Iftheuserpressestheactionbutton...
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Selecteditem'spath:"&vrtSelectedItem
NextvrtSelectedItem
'IftheuserpressesCancel...
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Setfd=Nothing
Page 696
InitialViewPropertyReturnsorsetsanMsoFileDialogViewconstantrepresentingtheinitialpresentationoffilesandfoldersinafiledialogbox.Read/write.
MsoFileDialogViewcanbeoneoftheseMsoFileDialogViewconstants.msoFileDialogViewDetailsmsoFileDialogViewLargeIconsmsoFileDialogViewListmsoFileDialogViewPreviewmsoFileDialogViewPropertiesmsoFileDialogViewSmallIconsmsoFileDialogViewThumbnailThisconstantisonlyavailableinconjunctionwithMicrosoftWindows2000orMicrosoftWindowsMillenniumEdition,orlater.msoFileDialogViewWebViewNotavailable.Ifyouselectthisconstant,thedefaultviewwillbeused.
expression.InitialView
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 697
Example
ThefollowingexampledisplaysaFilePickerdialogboxindetailsviewusingtheFileDialogobjectanddisplayseachselectedfileinamessagebox.
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'Settheinitialviewtothedetailsview.
.InitialView=msoFileDialogViewDetails
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Iftheuserpressestheactionbutton...
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Selecteditem'spath:"&vrtSelectedItem
NextvrtSelectedItem
'IftheuserpressesCancel...
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Setfd=Nothing
Page 699
IntroductionPropertySetsorreturnstheintroductorytextthatisincludedwithadocumentthatissentusingtheMsoEnvelopeobject.Theintroductorytextisincludedatthetopofthedocumentinthee-mail.Read/writeString.
expression.Introduction
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 700
Example
ThefollowingexamplesendstheactiveMicrosoftWorddocumentasane-mailtothee-mailaddressthatyoupasstothesubroutine.
SubSendMail(ByValstrRecipientAsString)
'UseaWith...EndWithblocktoreferencetheMsoEnvelopeobject.
WithApplication.ActiveDocument.MailEnvelope
'Addsomeintroductorytextbeforethebodyofthee-mail.
.Introduction="Pleasereadthisandsendmeyourcomments."
'ReturnaMailItemobjectthatyoucanusetosendthedocument.
With.Item
'Allofthemailitemsettingsaresavedwiththedocument.
'WhenyouaddarecipienttotheRecipientscollection
'orchangeotherpropertiesthesesettingswillpersist.
.Recipients.AddstrRecipient
.Subject="Hereisthedocument."
'Thebodyofthismessagewillbe
'thecontentoftheactivedocument.
.Send
EndWith
EndWith
EndSub
Page 701
IsCertificateExpiredPropertyTrueifthedigitalcertificatethatcorrespondstotheSignatureobjecthasexpired.Read-onlyBoolean.
expression.IsCertificateExpired
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 702
Example
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandpassthisfunctionthenameofacertificateissuerandthenameofacertificatesignerthatmatchtheIssuedByandIssuedTofieldsofadigitalcertificateintheDigitalCertificatesdialogbox.Thisexamplewilltesttomakesurethatthedigitalsignaturethattheuserselectsmeetscertaincriteria,suchasnothavingexpired,beforethenewsignatureiscommittedtothedisk.
FunctionAddSignature(ByValstrIssuerAsString,_
strSignerAsString)AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
'TestseveralpropertiesbeforecommitingtheSignatureobjecttodisk.
Ifsig.Issuer=strIssuerAnd_
sig.Signer=strSignerAnd_
sig.IsCertificateExpired=FalseAnd_
sig.IsCertificateRevoked=FalseAnd_
sig.IsValid=TrueThen
MsgBox"Signed"
AddSignature=True
'Otherwise,removetheSignatureobjectfromtheSignatureSetcollection.
Else
sig.Delete
MsgBox"Notsigned"
AddSignature=False
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Page 703
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 704
IsCertificateRevokedPropertyTrueifthedigitalcertificatethatcorrespondstotheSignatureobjecthasbeenrevokedbytheissuerofthecertificate.Read-onlyBoolean.
expression.IsCertificateRevoked
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 705
Example
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandpassthisfunctionthenameofacertificateissuerandthenameofacertificatesignerthatmatchtheIssuedByandIssuedTofieldsofadigitalcertificateintheDigitalCertificatesdialogbox.Thisexamplewilltesttomakesurethatthedigitalsignaturethattheuserselectsmeetscertaincriteria,suchasnothavingexpired,beforethenewsignatureiscommittedtothedisk.
FunctionAddSignature(ByValstrIssuerAsString,_
strSignerAsString)AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
'TestseveralpropertiesbeforecommitingtheSignatureobjecttodisk.
Ifsig.Issuer=strIssuerAnd_
sig.Signer=strSignerAnd_
sig.IsCertificateExpired=FalseAnd_
sig.IsCertificateRevoked=FalseAnd_
sig.IsValid=TrueThen
MsgBox"Signed"
AddSignature=True
'Otherwise,removetheSignatureobjectfromtheSignatureSetcollection.
Else
sig.Delete
MsgBox"Notsigned"
AddSignature=False
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Page 706
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 707
IsOpenPropertyTrueifthespecifiedHTMLprojectitemisopenintheMicrosoftScriptEditor.Read-onlyBoolean.
Page 708
Example
ThisexampledetermineswhetherthespecifiedHTMLprojectitemisopen.andifitis,theexamplethenloadsscriptfromthespecifiedfile.
IfActiveWorkbook.HTMLProject.HTMLProjectItems_
.Item(1).IsOpenThen
ActiveWorkbook.HTMLProject.HTMLProjectItems_
.Item(1).LoadFromFile("C:\MyScript.txt")
Else
MsgBox"TheHTMLProjectItemisnotopen."
EndIf
Page 709
IsPriorityDroppedPropertyTrueifthecontroliscurrentlydroppedfromthemenuortoolbarbasedonusagestatisticsandlayoutspace.(Notethatthisisnotthesameasthecontrol'svisibility,assetbytheVisibleproperty.)AcontrolwithVisiblesettoTrue,willnotbeimmediatelyvisibleonaPersonalizedMenuorToolbarifIsPriorityDroppedisTrue.Read-onlyBoolean.
Page 710
Remarks
TodeterminewhentosetIsPriorityDroppedtoTrueforaspecificmenuitem,MicrosoftOfficemaintainsatotalcountofthenumberoftimesthemenuitemwasusedandarecordofthenumberofdifferentapplicationsessionsinwhichtheuserhasusedanothermenuiteminthesamemenuasthismenuitem,withoutusingthespecificmenuitem.Whenthisvaluereachescertainthresholdvalues,thecountisdecremented.Whenthecountreacheszero,IsPriorityDroppedissettoTrue.Programmerscannotsetthesessionvalue,thethresholdvalue,ortheIsPriorityDroppedproperty.Programmerscan,however,usetheAdaptiveMenuspropertytodisableadaptivemenusforspecificmenusinanapplication.
TodeterminewhentosetIsPriorityDroppedtoTrueforaspecifictoolbarcontrol,Officemaintainsalistoftheorderinwhichallthecontrolsonthattoolbarwerelastexecuted.Atoolbarwillalwaysshowasmanycontrolsasithasspacetoshow,intheorderofmostrecentlyusedtoleastrecentlyused.ControlswithPrioritysetto1willalwaysbeshownandthetoolbarwillwraprows,ifnecessary,toshowthesecontrols.ProgrammerscanusethePrioritypropertytoensurethatspecifictoolbarcontrolsarealwaysshown,ortorepositiontoolbarssothattheyhaveenoughspacetodisplayalloftheircontrols.
YoucanusethefollowingtabletopredictthenumberofsessionsforwhichamenuitemonaPersonalizedMenuwillremainvisiblebeforethemenuitem'sIsPriorityDroppedpropertyissettoTrue.
Numberofusesofthecommandbarcontrol
Numberofsessionsoftheapplication
0,1 32 63 94,5 126–8 179–13 2314–24 2925ormore 31
Page 711
Example
ThisexamplecheckstheIsPriorityDroppedpropertyforthefirstcontrolonthecommandbarnamed“Custom.”IfIsPriorityDroppedisTrue,theexamplesetstheAdaptiveMenuspropertytoFalse,restoringthedroppedcommandbar.
IfCommandBars("Custom").Controls(1).IsPriorityDroppedThen
CommandBars.AdaptiveMenus=True
EndIf
Page 712
IssuerPropertyReturnsaStringrepresentingthenameoftheissuerofthedigitalcertificatethatcorrespondstotheSignatureobject.Read-only.
expression.Issuer
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 713
Example
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandpassthisfunctionthenameofacertificateissuerandthenameofacertificatesignerthatmatchtheIssuedByandIssuedTofieldsofadigitalcertificateintheDigitalCertificatesdialogbox.Thisexamplewilltesttomakesurethatthedigitalsignaturethattheuserselectsmeetscertaincriteria,suchasnothavingexpired,beforethenewsignatureiscommittedtothedisk.
FunctionAddSignature(ByValstrIssuerAsString,_
strSignerAsString)AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
'TestseveralpropertiesbeforecommitingtheSignatureobjecttodisk.
Ifsig.Issuer=strIssuerAnd_
sig.Signer=strSignerAnd_
sig.IsCertificateExpired=FalseAnd_
sig.IsCertificateRevoked=FalseAnd_
sig.IsValid=TrueThen
MsgBox"Signed"
AddSignature=True
'Otherwise,removetheSignatureobjectfromtheSignatureSetcollection.
Else
sig.Delete
MsgBox"Notsigned"
AddSignature=False
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Page 714
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 715
IsValidPropertyTrueifthedigitalsignaturethatcorrespondstotheSignatureobjectisavalidsignature.Asignaturemaybeinvalidforseveralreasonsrangingfromitscertificatehavingexpiredtochangesinthedocumentthatcontainsit.Read-onlyBoolean.
expression.IsValid
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 716
Example
ThefollowingexamplepromptstheusertoselectadigitalcertificatewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandpassthisfunctionthenameofacertificateissuerandthenameofacertificatesignerthatmatchtheIssuedByandIssuedTofieldsofadigitalcertificateintheDigitalCertificatesdialogbox.Thisexamplewilltesttomakesurethatthedigitalcertificatethattheuserselectsmeetscertaincriteria,suchasnothavingexpired,beforethenewsignatureiscommittedtothedisk.
FunctionAddSignature(ByValstrIssuerAsString,_
strSignerAsString)AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalcertificate.
'Iftheuserselectsacertificate,
'thenasignatureiscreatedand
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.'
Setsig=ActiveDocument.Signatures.Add
'TestseveralpropertiesbeforecommitingtheSignatureobjecttodisk.
Ifsig.Issuer=strIssuerAnd_
sig.Signer=strSignerAnd_
sig.IsCertificateExpired=FalseAnd_
sig.IsCertificateRevoked=FalseAnd_
sig.IsValid=TrueThen
MsgBox"Signed"
AddSignature=True
'Otherwise,removetheSignatureobjectfromtheSignatureSetcollection.
Else
sig.Delete
MsgBox"Notsigned"
AddSignature=False
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
Page 717
ExitFunction
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 718
IsVersioningEnabledPropertyReturnsaBooleanvaluethatindicateswhetherthedocumentlibraryinwhichtheactivedocumentissavedontheserverisconfiguredtocreateabackupcopy,orversion,eachtimethefileiseditedontheWebsite.Read-onlyBoolean.
expression.IsVersioningEnabled()
expressionRequired.AnexpressionthatreturnsaDocumentLibraryVersionsobject.
Page 719
Remarks
Versioningisenabledordisabledonthedocumentlibraryandnotonindividualdocuments.ThereforethevalueoftheIsVersioningEnabledpropertydependsonthedocumentlibraryinwhichthedocumentissaved.
Page 720
Example
Thefollowingexampledisplaysthenumberofsavedversionsoftheactivedocument,ifversioningisenabled.
DimdlvVersionsAsOffice.DocumentLibraryVersions
SetdlvVersions=ActiveDocument.DocumentLibraryVersions
IfdlvVersions.IsVersioningEnabledThen
MsgBox"Thisdocumenthas"&dlvVersions.Count&_
"savedversions.",vbInformation+vbOKOnly,_
"VersionInformation"
Else
MsgBox"Versioningisnotenabledforthisdocument.",_
vbInformation+vbOKOnly,"NoVersioning"
EndIf
SetdlvVersions=Nothing
Page 722
ItemPropertyItempropertyasitappliestotheAnswerWizardFilesandFoundFiles
objects.
ReturnsafilenamestringfromanAnswerWizardFilescollection,orafilenamefromthelistoffilenamesrepresentedbytheFoundFilesobject,respectively.Read-onlyString.
expression.Item(Index)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
IndexRequiredLong.TheindexnumberoftheAnswerWizardfilenamestring,orthefilename,tobereturned.
ItempropertyasitappliestotheAssistant,BalloonCheckbox,BalloonLabel,andFileDialogobjects.
Returnsthetextassociatedwithanobject.Read-onlyString.
expression.Item
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
ItempropertyasitappliestotheBalloonCheckboxesandBalloonLabelsobjects.
ReturnsaBalloonCheckBoxorBalloonLabelobject.
expression.Item(Index)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
IndexRequiredLong.Theindexnumberofthecheckboxorlabeltobereturned.
Page 723
ItempropertyasitappliestotheCommandBarsobject.
ReturnsaCommandBarobjectfromtheCommandBarscollection.
expression.Item(Index)
expressionRequired.AnexpressionthatreturnsaCommandBarsobject.
IndexRequiredVariant.Thenameorindexnumberoftheobjecttobereturned.
ItempropertyasitappliestotheCommandBarControlsobject.
ReturnsaCommandBarControlobjectfromtheCommandBarControlscollection.
expression.Item(Index)
expressionRequired.AnexpressionthatreturnsaCommandBarControlsobject.
IndexRequiredVariant.Thenameorindexnumberoftheobjecttobereturned.
ItempropertyasitappliestotheDocumentLibraryVersionsobject.
ReturnsaDocumentLibraryVersionobjectfromtheDocumentLibraryVersionscollection.
expression.Item(Index)
expressionRequired.AnexpressionthatreturnsaDocumentLibraryVersionsobject.
IndexRequiredLong.TheindexnumberoftheDocumentLibraryVersionreturned.
ItempropertyasitappliestotheDocumentPropertiesobject.
Page 724
ReturnsaDocumentPropertyobjectfromtheDocumentPropertiescollection.
expression.Item(Index)
expressionRequired.AnexpressionthatreturnsaDocumentPropertiesobject.
IndexRequiredVariant.Thenameorindexnumberofthedocumentpropertyreturned.
ItempropertyasitappliestotheFileTypescollection.
ReturnsavaluethatindicateswhichfiletypewillbesearchedforbytheExecutemethodoftheFileSearchobject.Read-onlyMsoFileType.
MsoFileTypecanbeoneoftheseMsoFileTypeconstants.msoFileTypeAllFilesmsoFileTypeBindersmsoFileTypeCalendarItemmsoFileTypeContactItemmsoFileTypeDatabasesmsoFileTypeDataConnectionFilesmsoFileTypeDesignerFilesmsoFileTypeDocumentImagingFilesmsoFileTypeExcelWorkbooksmsoFileTypeJournalItemmsoFileTypeMailItemmsoFileTypeNoteItemmsoFileTypeOfficeFilesmsoFileTypeOutlookItemsmsoFileTypePhotoDrawFilesmsoFileTypePowerPointPresentationsmsoFileTypeProjectFilesmsoFileTypePublisherFilesmsoFileTypeTaskItem
Page 725
msoFileTypeTemplatesmsoFileTypeVisioFilesmsoFileTypeWebPagesmsoFileTypeWordDocuments
expression.Item(Index)
expressionRequired.AnexpressionthatreturnsaFileTypescollection.
IndexRequiredLong.Theindexnumberoftheobjecttobereturned.
ItempropertyasitappliestotheMsoEnvelopeobject.
ReturnsaMailItemobjectthatcanbeusedtosendthedocumentasane-mail.
expression.Item
expressionRequired.AnexpressionthatreturnsanMsoEnvelopeobject.
ItempropertyasitappliestothePermissionobject.
ReturnsaUserPermissionobjectthatisamemberofthePermissioncollection.TheUserPermissionobjectassociatesasetofpermissionsontheactivedocumentwithasingleuserandanoptionalexpirationdate.
expression.Item(Index)
expressionRequired.AnitemthatreturnsaPermissionobject.
IndexRequiredVariant.ThenumericindexoftheUserPermissioninthePermissioncollection,ortheemailaddressoftheuserwhosesetofpermissionsontheactivedocumentistobereturned.
ItempropertyasitappliestothePropertyTestsobject.
ReturnsaPropertyTestobjectfromthePropertyTestscollection.
expression.Item(Index)
Page 726
expressionRequired.AnexpressionthatreturnsaPropertyTestsobject.
IndexRequiredLong.Theindexnumberofthepropertytesttobereturned.
ItempropertyasitappliestotheScopeFoldersandSearchFoldersobjects.
ReturnsaScopeFolderobjectthatrepresentsasubfolderoftheparentobject.
expression.Item(Index)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
IndexRequiredLong.Determineswhichsubfoldertoreturn.
ItempropertyasitappliestotheSearchScopesobject.
ReturnsaSearchScopeobjectthatcorrespondstoanareainwhichtoperformafilesearch,suchaslocaldrivesorMicrosoftOutlookfolders.
expression.Item(Index)
expressionRequired.AnexpressionthatreturnsaSearchScopesobject.
IndexRequiredLong.DetermineswhichSearchScopeobjecttoreturn.
ItempropertyasitappliestotheSharedWorkspaceFilesobject.
ReturnsaSharedWorkspaceFileobjectfromtheFilescollectionofthesharedworkspace.
expression.Item(Index)
expressionRequired.ThespecifiedSharedWorkspaceFilescollection.
IndexRequiredLong.ReturnstheSharedWorkspaceFileatthepositionspecified.IndexdoesnotcorrespondtotheorderinwhichtheitemsaredisplayedintheSharedWorkspacepane,andisnotaffectedbyre-sortingthedisplay.
Page 727
ItempropertyasitappliestotheSharedWorkspaceFoldersobject.
ReturnsaSharedWorkspaceFolderobjectfromtheFolderscollectionofthesharedworkspace.
expression.Item(Index)
expressionRequired.ThespecifiedSharedWorkspaceFolderscollection.
IndexRequiredLong.ReturnstheSharedWorkspaceFolderatthepositionspecified.IndexdoesnotcorrespondtotheorderinwhichtheitemsaredisplayedintheSharedWorkspacepane,andisnotaffectedbyre-sortingthedisplay.
ItempropertyasitappliestotheSharedWorkspaceLinksobject.
ReturnsaSharedWorkspaceLinkobjectfromtheLinkscollectionofthesharedworkspace.
expression.Item(Index)
expressionRequired.ThespecifiedSharedWorkspaceLinkscollection.
IndexRequiredLong.ReturnstheSharedWorkspaceLinkatthepositionspecified.IndexdoesnotcorrespondtotheorderinwhichtheitemsaredisplayedintheSharedWorkspacepane,andisnotaffectedbyre-sortingthedisplay.
ItempropertyasitappliestotheSharedWorkspaceMembersobject.
ReturnsaSharedWorkspaceMemberobjectfromtheMemberscollectionofthesharedworkspace.
expression.Item(Index)
expressionRequired.ThespecifiedSharedWorkspaceMemberscollection.
IndexRequiredLong.ReturnstheSharedWorkspaceMemberatthepositionspecified.Indexdoesnotcorrespondtotheorderinwhichtheitemsare
Page 728
displayedintheSharedWorkspacepane.
ItempropertyasitappliestotheSharedWorkspaceTasksobject.
ReturnsaSharedWorkspaceTaskobjectfromtheTaskscollectionofthesharedworkspace.
expression.Item(Index)
expressionRequired.ThespecifiedSharedWorkspaceTaskscollection.
IndexRequiredLong.ReturnstheSharedWorkspaceTaskatthepositionspecified.IndexdoesnotcorrespondtotheorderinwhichtheitemsaredisplayedintheSharedWorkspacepane,andisnotaffectedbyre-sortingthedisplay.
ItempropertyasitappliestotheSignatureSetobject.
ReturnsaSignatureobjectthatcorrespondstooneofthedigitalsignatureswithwhichthedocumentiscurrentlysigned.
expression.Item(iSig)
expressionRequired.AnexpressionthatreturnsaSignatureSetobject.
iSigRequiredLong.DetermineswhichSignatureobjecttoreturn.
ItempropertyasitappliestotheWebPageFontsobject.
ReturnsaWebPageFontobjectfromtheWebPageFontscollectionforaparticularvalueofMsoCharacterSet.
expression.Item(Index)
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
IndexRequiredMsoCharacterSet.Thespecifiedcharacterset.
MsoCharacterSetcanbeoneoftheseMsoCharacterSetconstants.
Page 729
msoCharacterSetArabicmsoCharacterSetCyrillicmsoCharacterSetEnglishWesternEuropeanOtherLatinScriptmsoCharacterSetGreekmsoCharacterSetHebrewmsoCharacterSetJapanesemsoCharacterSetKoreanmsoCharacterSetMultilingualUnicodemsoCharacterSetSimplifiedChinesemsoCharacterSetThaimsoCharacterSetTraditionalChinesemsoCharacterSetVietnamese
Page 730
Example
AsitappliestotheAnswerWizardFilesandFoundFilesobjects.
ThisexampleresetsthefilelistforthecurrentAnswerWizardanddisplaysboththefilecountandthefilenamesinamessagebox,usingtheItempropertytoreturnthefilenames.
DimcustomAnswerWizardAsAnswerWizard
DimstrFileListAsString
DimintCounterAsInteger
DimintNumFilesAsInteger
SetcustomAnswerWizard=Application.AnswerWizard
intCounter=1
customAnswerWizard.ResetFileList
strFileList=""
intNumFiles=customAnswerWizard.Files.Count
ForintCounter=1To(intNumFiles)
strFileList=strFileList&_
customAnswerWizard.Files.Item(intCounter)&Chr(13)
Next
MsgBox"Thereare"&customAnswerWizard.Files.Count&_
"filesavaialblethroughthisAnswerWizard:"&_
Chr(13)&strFileList
AsitappliestotheBalloonCheckboxesandBalloonLabelsobjects.
Itemisthedefaultmemberoftheobjectorcollection.ThefollowingtwostatementsbothassigntolblTextthetextofthefirstlabelintheBalloonobjectassignedtomyBalloon.
lblText=myBalloon.Labels(1).Item
lblText=myBalloon.Labels(1)
AsitappliestotheCommandBarsobject.
Itemisthedefaultmemberoftheobjectorcollection.ThefollowingtwostatementsbothassignaCommandBarobjecttocmdBar.
Page 731
SetcmdBar=CommandBars.Item("Standard")
SetcmdBar=CommandBars("Standard")
AsitappliestotheMsoEnvelopeobject.
ThefollowingexamplesendstheactiveMicrosoftWorddocumentasane-mailtothee-mailaddressthatyoupasstothesubroutine.
SubSendMail(ByValstrRecipientAsString)
'UseaWith...EndWithblocktoreferencethemsoEnvelopeobject.
WithApplication.ActiveDocument.MailEnvelope
'Addsomeintroductorytextbeforethebodyofthee-mailmessage.
.Introduction="Pleasereadthisandsendmeyourcomments."
'ReturnaMailItemobjectthatyoucanusetosendthedocument.
With.Item
'Allofthemailitemsettingsaresavedwiththedocument.
'WhenyouaddarecipienttotheRecipientscollection
'orchangeotherpropertiesthesesettingswillpersist.
.Recipients.AddstrRecipient
.Subject="Hereisthedocument."
'Thebodyofthismessagewillbe
'thecontentoftheactivedocument.
.Send
EndWith
EndWith
EndSub
AsitappliestotheWebPageFontsobject.
ThefollowingexampleusestheItempropertytosetmyFonttotheWebPageFontobjectfortheEnglish/WesternEuropean/OtherLatinScriptcharactersetintheactiveapplication.
DimmyFontAsWebPageFont
SetmyFont=_
Application.DefaultWebOptions.Fonts._
Item(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)
Page 733
ItemCountExceededPropertyReturnsaBooleanvaluethatindicateswhetherthenumberofitemsinthecollectionhasexceededthe99thatcanbedisplayedintheSharedWorkspacetaskpane.Read-onlyBoolean.
expression.Connected
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 734
Remarks
TheSharedWorkspacetaskpanecanonlydisplay99sharedworkspacefilesandfolders,links,members,ortasks.Ifmorethan99itemsareaddedtoanyofthesecollections:
thecorrespondingtaboftheSharedWorkspacetaskpanewillstopdisplayingthelistofitemsandwilldisplayalinktothesharedworkspacesitewebpageinstead;thecollectionwillnolongerbepopulatedlocallyanditsCountpropertywillreturn0(zero).
Furthermore,oncetheItemCountExceededpropertyreturnsTrueforoneofthecollectionslistedabove,thedevelopercannolongerremedythesituationprogrammaticallybydeletingitemsfromthecollectiontoreducethecountbelow99,becausethecollectionisnolongerpopulated.
TheItemCountExceededpropertyoftheSharedWorkspaceFilesandtheSharedWorkspaceFolderscollectionsreturnsTruewhenthecombinedCountoffilesandfoldersexceeds99,sincebothlistsarecombinedanddisplayedtogetherontheDocumentstaboftheSharedWorkspacetaskpane.
Page 735
Example
ThefollowingexamplecheckstheCountpropertyoftheSharedWorkspaceLinkscollection.IfCountreturns0(zero),itcheckstheItemCountExceededpropertytodeterminewhetherinfactthesharedworkspacehasnosavedlinks,orwhetherithasmorethan99andthelinkscollectionhasbeencleared.
ActiveWorkbook.SharedWorkspace.Refresh
IfActiveWorkbook.SharedWorkspace.Links.Count=0Then
IfActiveWorkbook.SharedWorkspace.Links.ItemCountExceededThen
MsgBox"Morethan99linksinsharedworkspace.",_
vbInformation+vbOKOnly,"ItemCountExceeded"
Else
MsgBox"Nolinksinsharedworkspace.",_
vbInformation+vbOKOnly,"NoLinks"
EndIf
EndIf
Page 736
KeyboardShortcutTipsPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantdisplaysHelpaboutkeyboardshortcuts.Read/writeBoolean.
Page 737
Remarks
TheKeyboardShortcutTipspropertycorrespondstotheKeyboardshortcutsoptionintheShowtipsaboutsectionontheOptionstabintheOfficeAssistantdialogbox.
Page 738
Example
ThisexamplesetstheOfficeAssistanttoprovideHelpinformationaboutkeyboardshortcuts.
Assistant.KeyboardShortcutTips=True
Page 739
LabelsPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ReturnsaBalloonLabelscollectionthatrepresentsthebuttonlabels,numberlabels,andbulletlabelscontainedinthespecifiedOfficeAssistantballoon.Read-only.
Forinformationaboutreturningasinglememberofacollection,seeReturninganObjectfromaCollection.
Page 740
Example
Thisexamplecreatesaballooncontainingthreechoices.ThevariablexissettothereturnvalueoftheShowmethod,whichwillbe1,2or3,dependingonthelabeltheuserclicks.Intheexample,amessageboxdisplaysthevalueofthevariablex,butyoucanpassthevaluetoanotherprocedureoryoucanusethevalueinaSelectCasestatement.
Setb=Assistant.NewBalloon
Withb
.Heading="Thisismyheading"
.Text="Selectoneofthesethings:"
.Labels(1).Text="ChoiceOne"
.Labels(2).Text="ChoiceTwo"
.Labels(3).Text="ChoiceThree"
x=.Show
EndWith
MsgBoxx
Page 742
LanguagePropertySpecifiesorreturnsthescriptinglanguageoftheactivescript.Read/writeMsoScriptLanguage.
MsoScriptLanguagecanbeoneoftheseMsoScriptLanguageconstants.msoScriptLanguageASPmsoScriptLanguageJavamsoScriptLanguageOthermsoScriptLanguageVisualBasic
Page 743
Remarks
TheMsoScriptLanguageconstantsusedwiththeLanguagepropertyarealsousedintheLanguageparameterintheAddmethodoftheScriptscollection.
Page 744
Example
ThisexamplecheckstheLanguagepropertytoensurethatthefirstscriptinworksheetoneintheactiveworkbookiswritteninVBScript.
IfActiveWorkbook.Worksheets(1).Scripts(1).Language<>_
msoScriptLanguageVisualBasicThen
MsgBox"LanguageisnotsettoVBScript."
EndIf
Page 746
LanguageIDPropertyReturnsthelocaleidentifier(LCID)fortheinstalllanguage,theuserinterfacelanguage,ortheHelplanguage.Read-onlyLong.
expression.LanguageID(Id)
expressionRequired.AnexpressionthatreturnsaLanguageSettingsobject.
IdRequiredMsoAppLanguageID.
MsoAppLanguageIDconstant Meaning
msoLanguageIDExeMode
Thelanguagemodethattheapplicationisusing.ThissettingappliesonlytoMicrosoftExcelandMicrosoftAccess.Thissettingaffectslanguagesthatcanbedisplayedandedited,availablelanguage-specificfeatures,numberstyles,currencysettings,andsoforth.
IfnoneofthelanguagessupportedbyExcelandAccessareused,thehostapplicationwillnotbeconfiguredtosupportright-to-leftandEastAsianlanguages.Thesupportedlanguagesareasfollows:
ArabicFarsiHebrewJapaneseKoreanSimplifiedChineseTraditionalChineseUrduYiddish
msoLanguageIDHelp ThelanguageusedforonlineHelp.
Page 747
msoLanguageIDInstall
ThelanguagesettingsusedbyMicrosoftOfficetosetupdefaults.Forexample,MicrosoftWordusesthissettingtodeterminethelayoutoftoolbarsandthedefaulttypesofbulletsandnumbersonalanguage-by-languagebasis.
msoLanguageIDUI Thelanguageusedbythehostapplication'suserinterface.
msoLanguageIDUIPrevious
Thelanguagesettingfortheuserinterfacewhenagivencomputerwaslastrebooted.Aprogramoradd-incanusethistodeterminewhethertheuserinterfacelanguagehaschanged.
Page 748
Example
ThisMicrosoftExcelexamplecheckstheLanguageIDpropertysettingsfortheuserinterfaceandexecutionmodetoverifythattheyaresettothesameLCID.Theexamplereturnsanerrorifthereisadiscrepancy.
IfApplication.LanguageSettings.LanguageID(msoLanguageIDExeMode)_
<>Application.LanguageSettings.LanguageID(msoLanguageIDUI)_
ThenMsgBox"Theuserinterfacelanguageandexecution"&_
"modearedifferent."
Page 750
LanguagePreferredForEditingPropertyReturnsTrueifthevalueforthemsoLanguageIDconstanthasbeenidentifiedintheWindowsregistryasapreferredlanguageforediting.Read-onlyBoolean.
expression.LanguagePreferredForEditing(lid)
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
lidRequiredMsoLanguageID.
MsoLanguageIDcanbeoneoftheseMsoLanguageIDconstants.msoLanguageIDAfrikaansmsoLanguageIDAlbanianmsoLanguageIDAmharicmsoLanguageIDArabicmsoLanguageIDArabicAlgeriamsoLanguageIDArabicBahrainmsoLanguageIDArabicEgyptmsoLanguageIDArabicIraqmsoLanguageIDArabicJordanmsoLanguageIDArabicKuwaitmsoLanguageIDArabicLebanonmsoLanguageIDArabicLibyamsoLanguageIDArabicMoroccomsoLanguageIDArabicOmanmsoLanguageIDArabicQatarmsoLanguageIDArabicSyriamsoLanguageIDArabicTunisiamsoLanguageIDArabicUAE
Page 751
msoLanguageIDArabicYemenmsoLanguageIDArmenianmsoLanguageIDAssamesemsoLanguageIDAzeriCyrillicmsoLanguageIDAzeriLatinmsoLanguageIDBasquemsoLanguageIDBelgianDutchmsoLanguageIDBelgianFrenchmsoLanguageIDBengalimsoLanguageIDBrazilianPortuguesemsoLanguageIDBulgarianmsoLanguageIDBurmesemsoLanguageIDByelorussianmsoLanguageIDCatalanmsoLanguageIDCherokeemsoLanguageIDChineseHongKongmsoLanguageIDChineseMacaomsoLanguageIDChineseSingaporemsoLanguageIDCroatianmsoLanguageIDCzechmsoLanguageIDDanishmsoLanguageIDDutchmsoLanguageIDEnglishAUSmsoLanguageIDEnglishBelizemsoLanguageIDEnglishCanadianmsoLanguageIDEnglishCaribbeanmsoLanguageIDEnglishIrelandmsoLanguageIDEnglishJamaicamsoLanguageIDEnglishNewZealandmsoLanguageIDEnglishPhilippinesmsoLanguageIDEnglishSouthAfricamsoLanguageIDEnglishTrinidadmsoLanguageIDEnglishUK
Page 752
msoLanguageIDEnglishUSmsoLanguageIDEnglishZimbabwemsoLanguageIDEstonianmsoLanguageIDFaeroesemsoLanguageIDFarsimsoLanguageIDFinnishmsoLanguageIDFrenchmsoLanguageIDFrenchCameroonmsoLanguageIDFrenchCanadianmsoLanguageIDFrenchCotedIvoiremsoLanguageIDFrenchLuxembourgmsoLanguageIDFrenchMalimsoLanguageIDFrenchMonacomsoLanguageIDFrenchReunionmsoLanguageIDFrenchSenegalmsoLanguageIDFrenchWestIndiesmsoLanguageIDFrenchZairemsoLanguageIDFrisianNetherlandsmsoLanguageIDGaelicIrelandmsoLanguageIDGaelicScotlandmsoLanguageIDGalicianmsoLanguageIDGeorgianmsoLanguageIDGermanmsoLanguageIDGermanAustriamsoLanguageIDGermanLiechtensteinmsoLanguageIDGermanLuxembourgmsoLanguageIDGreekmsoLanguageIDGujaratimsoLanguageIDHebrewmsoLanguageIDHindimsoLanguageIDHungarianmsoLanguageIDIcelandicmsoLanguageIDIndonesian
Page 753
msoLanguageIDInuktitutmsoLanguageIDItalianmsoLanguageIDJapanesemsoLanguageIDKannadamsoLanguageIDKashmirimsoLanguageIDKazakhmsoLanguageIDKhmermsoLanguageIDKirghizmsoLanguageIDKonkanimsoLanguageIDKoreanmsoLanguageIDLaomsoLanguageIDLatvianmsoLanguageIDLithuanianmsoLanguageIDMacedonianmsoLanguageIDMalayalammsoLanguageIDMalayBruneiDarussalammsoLanguageIDMalaysianmsoLanguageIDMaltesemsoLanguageIDManipurimsoLanguageIDMarathimsoLanguageIDMexicanSpanishmsoLanguageIDMixedmsoLanguageIDMongolianmsoLanguageIDNepalimsoLanguageIDNonemsoLanguageIDNoProofingmsoLanguageIDNorwegianBokmolmsoLanguageIDNorwegianNynorskmsoLanguageIDOriyamsoLanguageIDOromomsoLanguageIDPolishmsoLanguageIDPortuguesemsoLanguageIDPunjabi
Page 754
msoLanguageIDRhaetoRomanicmsoLanguageIDRomanianmsoLanguageIDRomanianMoldovamsoLanguageIDRussianmsoLanguageIDRussianMoldovamsoLanguageIDSamiLappishmsoLanguageIDSanskritmsoLanguageIDSerbianCyrillicmsoLanguageIDSerbianLatinmsoLanguageIDSesothomsoLanguageIDSimplifiedChinesemsoLanguageIDSindhimsoLanguageIDSlovakmsoLanguageIDSlovenianmsoLanguageIDSorbianmsoLanguageIDSpanishmsoLanguageIDSpanishArgentinamsoLanguageIDSpanishBoliviamsoLanguageIDSpanishChilemsoLanguageIDSpanishColombiamsoLanguageIDSpanishCostaRicamsoLanguageIDSpanishDominicanRepublicmsoLanguageIDSpanishEcuadormsoLanguageIDSpanishElSalvadormsoLanguageIDSpanishGuatemalamsoLanguageIDSpanishHondurasmsoLanguageIDSpanishModernSortmsoLanguageIDSpanishNicaraguamsoLanguageIDSpanishPanamamsoLanguageIDSpanishParaguaymsoLanguageIDSpanishPerumsoLanguageIDSpanishPuertoRicomsoLanguageIDSpanishUruguay
Page 755
msoLanguageIDSpanishVenezuelamsoLanguageIDSutumsoLanguageIDSwahilimsoLanguageIDSwedishmsoLanguageIDSwedishFinlandmsoLanguageIDSwissFrenchmsoLanguageIDSwissGermanmsoLanguageIDSwissItalianmsoLanguageIDTajikmsoLanguageIDTamilmsoLanguageIDTatarmsoLanguageIDTelugumsoLanguageIDThaimsoLanguageIDTibetanmsoLanguageIDTigrignaEritreamsoLanguageIDTigrignaEthiopicmsoLanguageIDTraditionalChinesemsoLanguageIDTsongamsoLanguageIDTswanamsoLanguageIDTurkishmsoLanguageIDTurkmenmsoLanguageIDUkrainianmsoLanguageIDUrdumsoLanguageIDUzbekCyrillicmsoLanguageIDUzbekLatinmsoLanguageIDVendamsoLanguageIDVietnamesemsoLanguageIDWelshmsoLanguageIDXhosamsoLanguageIDZulu
Page 756
Remarks
YoumusttestallvalidmsoLanguageIDvaluestoenumeratethesetofpreferredlanguages.
Page 757
Example
ThisexampledisplaysamessageifU.S.Englishisapreferrededitinglanguage.
IfApplication.LanguageSettings._
LanguagePreferredForEditing(msoLanguageIDEnglishUS)Then
MsgBox"OneofthepreferrededitinglanguagesisUSEnglish."
EndIf
Page 758
LargeButtonsPropertyTrueifthetoolbarbuttonsdisplayedarelargerthannormalsize.Read/writeBoolean.
Page 759
Example
Thisexampletogglesthedisplaysizeoftoolbarbuttonsonallcommandbars.
SetallBars=CommandBars
IfallBars.LargeButtonsThen
allBars.LargeButtons=False
Else
allBars.LargeButtons=True
EndIf
Page 761
LastModifiedPropertyReturnsorsetsaconstantthatrepresentstheamountoftimesincethespecifiedfilewaslastmodifiedandsaved.ThedefaultvalueismsoLastModifiedAnyTime.Read/writeMsoLastModified.
MsoLastModifiedcanbeoneoftheseMsoLastModifiedconstants.msoLastModifiedAnyTimemsoLastModifiedLastMonthmsoLastModifiedLastWeekmsoLastModifiedThisMonthmsoLastModifiedThisWeekmsoLastModifiedTodaymsoLastModifiedYesterday
Page 762
Example
Thisexamplesetsoptionsforafilesearch.ThefilesthissearchreturnsweremodifiedyesterdayandarelocatedintheC:\MyDocumentsfolderorinoneofitssubfolders.
Setfs=Application.FileSearch
Withfs
.LookIn="C:\MyDocuments"
.SearchSubFolders=True
.LastModified=msoLastModifiedYesterday
EndWith
Page 763
LastRefreshedPropertyReturnsthedateandtimewhentheRefreshmethodwasmostrecentlycalled.Read-onlyVariant.
expression.LastRefreshed
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 764
Remarks
TheLastRefreshedpropertyraisesanerroriftheRefreshmethodhasneverbeencalled.
Page 765
Example
Thefollowingexamplerefreshesthesharedworkspaceifithasnotbeenrefreshedinthelast3minutes.Theexamplealsohandlestheerrorconditionwheretheworkspacehasnotyetbeenrefreshed.
OnErrorGoToerr_NeverRefreshed
IfDateDiff("s",ActiveWorkbook.SharedWorkspace.LastRefreshed,Now)>180Then
ActiveWorkbook.SharedWorkspace.Refresh
EndIf
ExitSub
err_NeverRefreshed:
ActiveWorkbook.SharedWorkspace.Refresh
Page 766
LastSyncTimePropertyReturnsthedateandtimewhenthelocalcopyoftheactivedocumentwaslastsynchronizedwiththeservercopy.Read-onlyVariant.
expression.LastSyncTime
expressionRequired.AnexpressionthatreturnsaSyncobject.
Page 767
Remarks
UsetheLastSyncTimepropertytodeterminehowmuchtimehaselapsedsincethelocalcopyoftheactivedocumentwaslastsynchronizedwiththeservercopy.ChecktheStatuspropertytodeterminewhetherthelocalcopyandtheservercopyareoutofsync.
Iftheactivedocumentisnotconfiguredforsynchronizationbetweenthelocalcopyandtheservercopy,theLastSyncTimepropertyraisesarun-timeerror.
Page 768
Example
Thefollowingexamplealertstheuseranddisplaysthesyncstatusifmorethan24hourshaveelapsedsincetheLastSyncTime.
DimobjSyncAsOffice.Sync
DimdtmLastSyncAsDate
DimstrStatusAsString
SetobjSync=ActiveDocument.Sync
dtmLastSync=CDate(objSync.LastSyncTime)
IfDateDiff("h",dtmLastSync,Now)>24Then
strStatus="Documenthasnotbeensynced"&_
"withinthelast24hours."&vbCrLf&_
"Documentstatus:"&objSync.Status
MsgBoxstrStatus,vbInformation+vbOKOnly,"ErrorInformation"
EndIf
SetobjSync=Nothing
Page 770
LeftPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
LeftpropertyasitappliestotheAssistantandCommandBarobjects.
SetsorreturnsthehorizontalpositionoftheOfficeAssistantwindow(inpoints),orthedistance(inpixels)ofthecommandbar,fromtheleftedgeofthespecifiedobjectrelativetothescreen.Read/writeLong.
expression.Left
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
LeftpropertyasitappliestotheCommandBarButton,CommandBarComboBox,CommandBarControl,andCommandBarPopupobjects.
Setorreturnsthehorizontalpositionofthespecifiedcommandbarcontrol(inpixels)relativetotheleftedgeofthescreen.Returnsthedistancefromtheleftsideofthedockingarea.Read-onlyLong.
expression.Left
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 771
Example
AsitappliestotheAssistantandCommandBarobjects.
ThisexampledisplaystheOfficeAssistantandmovesittothespecifiedpositionwithintheapplicationwindow.
WithAssistant
.Visible=True
.Left=300
.Top=300
EndWith
ThisexamplemovesthecommandbarnamedCustomfromitsdockedpositionalongthetopofthewindowtotheleftedgeofthewindow.
SetmyBar=CommandBars("Custom")
WithmyBar
.Position=1
.RowIndex=2
.Left=0
EndWith
Page 772
LinksPropertyReturnsaSharedWorkspaceLinkscollectionthatrepresentsthelistoflinkssavedinthecurrentsharedworkspace.Read-only.
expression.Links()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 773
Example
Thefollowingexampleliststhelinkssavedinthecurrentsharedworkspace.
DimswsLinksAsOffice.SharedWorkspaceLinks
SetswsLinks=ActiveWorkbook.SharedWorkspace.Links
MsgBox"Thereare"&swsLinks.Count&_
"link(s)inthecurrentsharedworkspace.",_
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsLinks=Nothing
Page 774
LinkSourcePropertyReturnsorsetsthesourceofalinkedcustomdocumentproperty.Read/writeString.
Page 775
Remarks
Thispropertyappliesonlytocustomdocumentproperties;youcannotuseitwithbuilt-indocumentproperties.
Thesourceofthespecifiedlinkisdefinedbythecontainerapplication.
SettingtheLinkSourcepropertysetstheLinkToContentpropertytoTrue.
Page 776
Example
Thisexampledisplaysthelinkedstatusofacustomdocumentproperty.Fortheexampletowork,dpmustbeavalidDocumentPropertyobject.
SubDisplayLinkStatus(dpAsDocumentProperty)
DimstatAsString,tfAsString
Ifdp.LinkToContentThen
tf=""
Else
tf="not"
EndIf
stat="Thispropertyis"&tf&"linked"
Ifdp.LinkToContentThen
stat=stat+Chr(13)&"Thelinksourceis"&dp.LinkSource
EndIf
MsgBoxstat
EndSub
Page 777
LinkToContentPropertyTrueifthevalueofthecustomdocumentpropertyislinkedtothecontentofthecontainerdocument.Falseifthevalueisstatic.Read/writeBoolean.
Page 778
Remarks
Thispropertyappliesonlytocustomdocumentproperties.Forbuilt-indocumentproperties,thevalueofthispropertyisFalse.
UsetheLinkSourcepropertytosetthesourceforthespecifiedlinkedproperty.SettingtheLinkSourcepropertysetstheLinkToContentpropertytoTrue.
Page 779
Example
Thisexampledisplaysthelinkedstatusofthecustomdocumentproperty.Fortheexampletowork,dpmustbeavalidDocumentPropertyobject.
SubDisplayLinkStatus(dpAsDocumentProperty)
DimstatAsString,tfAsString
Ifdp.LinkToContentThen
tf=""
Else
tf="not"
EndIf
stat="Thispropertyis"&tf&"linked"
Ifdp.LinkToContentThen
stat=stat+Chr(13)&"Thelinksourceis"&dp.LinkSource
EndIf
MsgBoxstat
EndSub
Page 781
ListPropertyReturnsorsetsaniteminthecommandbarcomboboxcontrol.Read/writeString.
NoteThispropertyisread-onlyforbuilt-incomboboxcontrols.
expression.List(Index)
expressionRequired.AnexpressionthatreturnsaCommandBarComboBoxobject.
IndexRequiredLong.Thelistitemtobeset.
Page 782
Example
Thisexamplechecksthefourthlistiteminthecomboboxcontrolwhosecaptionis"StockData"onthecommandbarnamed"Custom."Iftheitemisn’t"ViewNews,"theexampledisplaysamessageadvisingtheuserthatthecomboboxmaybedamagedandaskstheusertoreinstalltheapplication.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
WithmyBar
.Controls.AddType:=msoControlComboBox,ID:=1
.Visible=True
EndWith
WithCommandBars("Custom").Controls(1)
.AddItem"GetStockQuote",1
.AddItem"ViewChart",2
.AddItem"ViewFundamentals",3
.AddItem"ViewNews",4
.Caption="StockData"
.DescriptionText="ViewDataForStock"
EndWith
IfCommandBars("Custom").Controls(1).List(4)_
<>"ViewNews"Then
MsgBox("StockDataappearstobedamaged."&_
"Pleasereinstallapplication.")
EndIf
Page 784
ListCountPropertyReturnsthenumberoflistitemsinacommandbarcomboboxcontrol.Read-onlyLong.
Page 785
Example
Thisexamplechecksthenumberofitemsinthecomboboxonthecommandbarnamed"Custom."Iftherearen’tthreeitemsinthelistthattheprocedureproduces,theexampledisplaysamessageadvisingtheuserthatthecomboboxmaybedamagedandaskstheusertoreinstalltheapplication.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
WithmyBar
.Controls.AddType:=msoControlComboBox,ID:=1
.Visible=True
EndWith
WithCommandBars("Custom").Controls(1)
.AddItem"GetStockQuote",1
.AddItem"ViewChart",2
.AddItem"ViewFundamentals",3
.Caption="StockData"
.DescriptionText="ViewDataForStock"
EndWith
IfCommandBars("Custom").Controls(1).ListCount_
<>4Then
MsgBox("ComboBoxappearstobedamaged."&_
"Pleasereinstall.")
EndIf
Page 787
ListHeaderCountPropertyReturnsorsetsthenumberoflistitemsinacommandbarcomboboxcontrolthatappearsabovetheseparatorline.Read/writeLong.
NoteThispropertyisread-onlyforbuilt-incomboboxcontrols.
Page 788
Remarks
AListHeaderCountpropertyvalueof–1indicatesthatthere'snoseparatorlineinthecomboboxcontrol.
Page 789
Example
Thisexampleaddsacomboboxcontroltothecommandbarnamed"Custom"andthenaddstwoitemstothecombobox.TheexampleusestheListHeaderCountpropertytodisplayaseparatorlinebetweenFirstItemandSecondIteminthecombobox.Theexamplealsosetsthenumberoflineitems,thewidthofthecombobox,andanemptydefaultforthecombobox.
SetmyBar=CommandBars("Custom")
SetmyControl=myBar.Controls.Add(Type:=msoControlComboBox)
WithmyControl
.AddItemText:="FirstItem",Index:=1
.AddItemText:="SecondItem",Index:=2
.DropDownLines=3
.DropDownWidth=75
.ListHeaderCount=1
EndWith
Page 791
ListIndexPropertyReturnsorsetstheindexnumberoftheselectediteminthelistportionofthecommandbarcomboboxcontrol.Ifnothingisselectedinthelist,thispropertyreturnszero.Read/writeLong.
NoteThispropertyfailswhenappliedtocontrolsotherthanlistcontrols.
Page 792
Remarks
SettingtheListIndexpropertycausesthespecifiedcontroltoselectthegivenitemandexecutetheappropriateactionintheapplication.
Page 793
Example
ThisexampleusestheListIndexpropertytodeterminethecorrectsubroutinetorun,basedontheselectioninthecomboboxonthecommandbarnamed“MyCustomBar.”BecausetheprocedureusesListIndex,thetextinthecomboboxcanbeanything.
SubprocessSelection()
DimuserChoiceAsLong
userChoice=CommandBars("MyCustomBar").Controls(1).ListIndex
SelectCaseuserChoice
Case1
chartcourse
Case2
displaygraph
CaseElse
MsgBox("Invalidchoice.Pleasechooseagain.")
EndSelect
EndSub
Page 795
LocationPropertyReturnsthelocationofthescriptanchorinthespecifiedHTMLdocument.Read-onlyMsoScriptLocation.
MsoScriptLocationcanbeoneoftheseMsoScriptLocationconstants.msoScriptLocationInBodymsoScriptLocationInHead
Page 796
Remarks
ScripttagsinanHTMLdocumentcanappearanywherebetweenthe<HTML>tagsinthedocument.InMicrosoftWord,Excel,orPowerPoint,onlythescriptanchorslocatedbetweenthe<BODY>tagsarevisible.AdditionalHTMLscriptthatappearsbeforeorafterthe<BODY>tagsisstoredinbutisn’tvisibletotheuser.
TheScriptscollectioncontainsallofthescriptanchorsthatappearinthedocument,whetherinsideoroutsideofthemainbodyofthedocument.UsingtheLocationargumentoftheAddmethod,youcaninsertscriptanchorswithinthe<HEAD>and<BODY>tagsintheHTMLdocument.YoucanalsousetheLocationpropertytodeterminewhereaparticularscriptanchorisstoredwithinthedocument.
Page 797
Example
ThisexamplecheckstheLocationpropertyofthefirstscriptinworksheetoneintheactiveworkbookanddisplaysthelocationinamessagebox.
IfActiveWorkbook.Worksheets(1).Scripts(1).Location=1Then
MsgBox"Thescriptinlocatedintheheader."
EndIf
IfActiveWorkbook.Worksheets(1).Scripts(1).Location=2Then
MsgBox"Thescriptinlocatedinthebodyoftheworksheet."
EndIf
Page 798
LookInPropertyReturnsorsetsthefoldertobesearchedduringthespecifiedfilesearch.Read/writeString.
Page 799
Example
ThisexamplesearchestheMyDocumentsfoldersforallfilesthatbeginwith"Cmd"anddisplaysthenameandlocationofeachfilethat’sfound.
Setfs=Application.FileSearch
Withfs
.LookIn="C:\MyDocuments"
.FileName="cmd*.*"
If.Execute>0Then
MsgBox"Therewere"&.FoundFiles.Count&_
"file(s)found."
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
Nexti
Else
MsgBox"Therewerenofilesfound."
EndIf
EndWith
Page 800
MaskPropertyReturnsanIPictureDispobjectrepresentingthemaskimageofaCommandBarButtonobject.Themaskimagedetermineswhatpartsofthebuttonimagearetransparent.
expression.Mask
expressionRequired.AnexpressionthatreturnsaCommandBarButtonobject.
Page 801
Remarks
Whenyoucreateanimagethatyouplanonusingasamaskimage,alloftheareasthatyouwanttobetransparentshouldbewhite,andalloftheareasthatyouwanttoshowshouldbeblack.
AlwayssetthemaskafteryouhavesetthepictureforaCommandBarButtonobject.
Page 802
Example
ThefollowingexamplesetstheimageandmaskofthefirstCommandBarButtonthatthecodereturns.Tomakethiswork,createamaskimageandabuttonimageandsustitutethepathsinthesamplewiththepathstoyourimages.
SubChangeButtonImage()
DimpicPictureAsIPictureDisp
DimpicMaskAsIPictureDisp
SetpicPicture=stdole.StdFunctions.LoadPicture(_
"c:\images\picture.bmp")
SetpicMask=stdole.StdFunctions.LoadPicture(_
"c:\images\mask.bmp")
'Referencethefirstbuttononthefirstcommandbar
'usingaWith...EndWithblock.
WithApplication.CommandBars.FindControl(msoControlButton)
'Changethebuttonimage.
.Picture=picPicture
'Usethesecondimagetodefinetheareaofthe
'buttonthatshouldbetransparent.
.Mask=picMask
EndWith
EndSub
ThefollowingexamplegetstheimageandmaskofthefirstCommandBarButtonthatthecodereturnsandoutputseachofthemtoafile.Tomakethiswork,specifyapathfortheoutputfiles.
SubGetButtonImageAndMask()
DimpicPictureAsIPictureDisp
DimpicMaskAsIPictureDisp
WithApplication.CommandBars.FindControl(msoControlButton)
'GetthebuttonimageandmaskofthisCommandBarButtonobject
SetpicPicture=.Picture
SetpicMask=.Mask
EndWith
'Savethebuttonimageandmaskinafolder.
stdole.SavePicturepicPicture,"c:\image.bmp"
Page 803
stdole.SavePicturepicMask,"c:\mask.bmp"
EndSub
Page 804
MatchAllWordFormsPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
Trueifthefilesearchisexpandedtoincludeallformsofthespecifiedwordcontainedinthebodyofthefile,orinthefile'sproperties.Read/writeBoolean.
Page 805
Remarks
ThispropertyisavailableonlyifthefileMswds_en.lexhasbeeninstalledandregistered.Notethatthisfileisn'tinstalledaspartofaTypicalsetup.
Page 806
Example
Thisexamplereturnsallfilesthatcontaintheword"run,""running,""runs,"or"ran"inthebodyofthefile,orinthepropertiesofthefile.TheTextOrPropertypropertysetsthewordtobematched,andlimitsthesearchtoeitherthebodyofthefileorthefileproperties.
WithApplication.FileSearch
.NewSearch
.LookIn="C:\MyDocuments"
.SearchSubFolders=True
.TextOrProperty="run"
.MatchAllWordForms=True
.FileType=msoFileTypeAllFiles
EndWith
Page 807
MatchTextExactlyPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
Trueifthespecifiedfilesearchwillfindonlyfileswhosebodytextorfilepropertiescontaintheexactwordorphrasethatyou'vespecified.Read/writeBoolean.
Page 808
Example
ThisexamplesearchestheC:\MyDocumentsfolderandreturnsallfilesthatcontaintheword"Run"eitherinthebodytextorinthefileproperties.
WithApplication.FileSearch
.NewSearch
.LookIn="C:\MyDocuments"
.TextOrProperty="Run"
.MatchTextExactly=True
.FileType=msoFileTypeAllFiles
EndWith
Page 809
MembersPropertyReturnsaSharedWorkspaceMemberscollectionthatrepresentsthelistofmembersinthecurrentsharedworkspace.Read-only.
expression.Members()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 810
Example
Thefollowingexampleliststhemembersinthecurrentsharedworkspace.
DimswsMembersAsOffice.SharedWorkspaceMembers
SetswsMembers=ActiveWorkbook.SharedWorkspace.Members
MsgBox"Thereare"&swsMembers.Count&_
"member(s)inthecurrentsharedworkspace.",_
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsMembers=Nothing
Page 812
MenuAnimationStylePropertyReturnsorsetsthewayacommandbarisanimated.Read/writeMsoMenuAnimation.
MsoMenuAnimationcanbeoneoftheseMsoMenuAnimationconstants.msoMenuAnimationNonemsoMenuAnimationRandommsoMenuAnimationSlidemsoMenuAnimationUnfold
Page 813
Example
ThisexamplesetsoptionsforallcommandbarsinMicrosoftOffice.
WithCommandBars
.LargeButtons=True
.DisplayTooltips=True
.DisplayKeysInTooltips=True
.MenuAnimationStyle=msoMenuAnimationUnfold
EndWith
Page 815
ModePropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ReturnsorsetsthemodalbehavioroftheOfficeAssistantballoon.WhenyoucreateaBalloonobject,thispropertyisinitiallysettomsoModeModal.Read/writeMsoModeType.
MsoModeTypecanbeoneoftheseMsoModeTypeconstants.msoModeAutoDownmsoModeModalmsoModeModeless
Page 816
Remarks
IftheModepropertyforaballoonissettomsoModeModeless,theusercanworkintheapplicationwhiletheballoonisvisible.IfthepropertyissettomsoModeModal,theusermustdismisstheballoonbeforecontinuingtoworkintheapplication.IfthepropertyissettomsoModeAutoDown,theballoonisdismissedwhentheuserclicksanywhereonthescreen.
IftheModepropertyforaballoonissettomsoModeModelessandavaluefortheCallbackpropertyisnotsupplied,anerroroccurs.TheClosemethodcanonlybeusedintheprocedurespecifiedbytheCallbackpropertywhentheModepropertyissettomsoModeModeless.
Page 817
Example
Thisexamplecreatesaballoonwithanalerticonthatinstructstheusertoselectaprinter.Becausetheballoonismodeless,theuserhasaccesstoprintercommandswhiletheballoonisvisible.WhentheuserclickstheOKbutton,theprocedurespecifiedintheCallbackpropertyisrun.
WithAssistant.NewBalloon
.Heading="SelectAPrinter"
.Text="Youmustselectaprinterbeforeprinting."
.Icon=msoIconAlert
.CheckBoxes(1).Text="Localprinter"
.CheckBoxes(2).Text="Networkprinter"
.Mode=msoModeModeless
.Callback="ProcessPrinter"
.Show
EndWith
Page 818
ModifiedPropertyReturnsthedateandtimeatwhichthespecifiedversionoftheshareddocumentwaslastsavedtotheserver.Read-onlyVariant.
expression.Modified
expressionRequired.AnexpressionthatreturnsaDocumentLibraryVersionobject.
Page 819
Remarks
Anewversioniscreatedontheservereachtimeauseropensthedocumentandisupdatedwhentheusersaveschanges;additionalversionsarenotcreatedeachtimetheusersaveschangestotheopendocument.TheModifiedpropertyoftheactivedocumentversionrepresentsthelasttimetheusersavedchangestotheopendocument.
Page 820
Example
ThefollowingexampledisplaystheModifieddateandtimealongwithotherpropertiesofeachversionofashareddocument.
DimdlvVersionsAsOffice.DocumentLibraryVersions
DimdlvVersionAsOffice.DocumentLibraryVersion
DimstrVersionInfoAsString
SetdlvVersions=ActiveDocument.DocumentLibraryVersions
IfdlvVersions.IsVersioningEnabledThen
strVersionInfo="Thisdocumenthas"&_
dlvVersions.Count&"versions:"&vbCrLf
ForEachdlvVersionIndlvVersions
strVersionInfo=strVersionInfo&_
"-Version#:"&dlvVersion.Index&vbCrLf&_
"-Modifiedby:"&dlvVersion.ModifiedBy&vbCrLf&_
"-Modifiedon:"&dlvVersion.Modified&vbCrLf&_
"-Comments:"&dlvVersion.Comments&vbCrLf
Next
Else
strVersionInfo="Versioningnotenabledforthisdocument."
EndIf
MsgBoxstrVersionInfo,vbInformation+vbOKOnly,"VersionInformation"
SetdlvVersion=Nothing
SetdlvVersions=Nothing
Page 822
ModifiedByPropertyAsitappliestotheDocumentLibraryVersionobject.
Returnsthenameoftheuserwholastsavedthespecifiedversionoftheshareddocumenttotheserver.Read-onlyString.
expression.ModifiedBy
expressionRequired.AnexpressionthatreturnsaDocumentLibraryVersionobject.
AsitappliestotheSharedWorkspaceFile,SharedWorkspaceLink,andSharedWorkspaceTaskobjects.
Returnsthenameoftheuserwholastmodifiedtheobject.Read-onlyString.
expression.ModifiedBy
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceFile,SharedWorkspaceLink,orSharedWorkspaceTaskobject.
Page 823
Remarks
Forsharedworkspaceobjects,theModifiedBypropertyreturnsthefriendlynamestoredintheNamepropertyoftheDWSMemberobject.
TheSharedWorkspaceFolderandSharedWorkspaceMemberobjectsdonothaveaModifiedByproperty.
Page 824
Example
AsitappliestotheDocumentLibraryVersionobject.
ThefollowingexampledisplaystheModifiedBynamealongwithotherpropertiesofeachversionofashareddocument.
DimdlvVersionsAsOffice.DocumentLibraryVersions
DimdlvVersionAsOffice.DocumentLibraryVersion
DimstrVersionInfoAsString
SetdlvVersions=ActiveDocument.DocumentLibraryVersions
IfdlvVersions.IsVersioningEnabledThen
strVersionInfo="Thisdocumenthas"&_
dlvVersions.Count&"versions:"&vbCrLf
ForEachdlvVersionIndlvVersions
strVersionInfo=strVersionInfo&_
"-Version#:"&dlvVersion.Index&vbCrLf&_
"-Modifiedby:"&dlvVersion.ModifiedBy&vbCrLf&_
"-Modifiedon:"&dlvVersion.Modified&vbCrLf&_
"-Comments:"&dlvVersion.Comments&vbCrLf
Next
Else
strVersionInfo="Versioningnotenabledforthisdocument."
EndIf
MsgBoxstrVersionInfo,vbInformation+vbOKOnly,"VersionInformation"
SetdlvVersion=Nothing
SetdlvVersions=Nothing
AsitappliestotheSharedWorkspaceFile,SharedWorkspaceLink,andSharedWorkspaceTaskobjects.
Thefollowingexampleliststhefilesinasharedworkspacethatwerelastmodifiedbyusersotherthanthecreatoroftheworkspace.
DimswsFileAsOffice.SharedWorkspaceFile
DimswsOwnerAsOffice.SharedWorkspaceMember
DimstrMemberFilesAsString
SetswsOwner=ActiveWorkbook.SharedWorkspace.Members(1)
ForEachswsFileInActiveWorkbook.SharedWorkspace.Files
IfswsFile.ModifiedBy<>swsOwner.NameThen
strMemberFiles=strMemberFiles&swsFile.URL&vbCrLf
EndIf
Next
MsgBox"Thesefileswerelastmodifiedbyotherusers:"&_
vbCrLf&strMemberFiles,_
Page 825
vbInformation+vbOKOnly,"FilesModifiedbyOtherUsers"
SetswsOwner=Nothing
SetswsFile=Nothing
Page 826
ModifiedDatePropertyReturnsthedateandtimewhenthesharedworkspaceobjectwaslastmodified.Read-onlyVariant.
expression.ModifiedDate
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 827
Remarks
TheSharedWorkspaceFolderandSharedWorkspaceMemberobjectsdonothaveaModifiedDateproperty.
Page 828
Example
Thefollowingexamplereturnsalistofsharedworkspacefileswhosedateandtimelastmodifiedisearlierthantoday.
DimswsFileAsOffice.SharedWorkspaceFile
DimdtmMidnightAsDate
DimdtmFileDateAsDate
DimstrOlderFilesAsString
dtmMidnight=CDate(FormatDateTime(Now,vbShortDate)&"12:00:00am")
ForEachswsFileInActiveWorkbook.SharedWorkspace.Files
dtmFileDate=swsFile.ModifiedDate
IfdtmFileDate<dtmMidnightThen
strOlderFiles=strOlderFiles&swsFile.URL&vbCrLf
EndIf
Next
MsgBox"Filesnotmodifiedtoday:"&vbCrLf&strOlderFiles,_
vbInformation+vbOKOnly,"OlderFiles"
SetswsFile=Nothing
Page 829
MouseTipsPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantprovidessuggestionsforusingthemouseeffectively.Read/writeBoolean.
Page 830
Remarks
TheMouseTipspropertycorrespondstotheUsingthemousemoreeffectivelyoptionunderShowtipsaboutontheOptionstabintheOfficeAssistantdialogbox.
Page 831
Example
ThisexamplesetstheOfficeAssistanttoprovidesuggestionsforusingthemouseeffectively.
Assistant.MouseTips=True
Page 832
MoveWhenInTheWayPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantwindowautomaticallymoveswhenit'sinthewayoftheuser'sworkarea.Forexample,theAssistantwillmoveifit'sinthewayofdraggingordroppingorinthewayofkeystrokeentries.Read/writeBoolean.
Page 833
Remarks
ThedefaultvalueisTrue.TheMoveWhenInTheWaypropertycorrespondstotheMovewheninthewayoptionintheUsetheOfficeAssistantsectionontheOptionstabintheOfficeAssistantdialogbox.
Page 834
Example
ThisexampledisplaystheOfficeAssistantinaspecificlocationanditsetsseveraloptionsbeforemakingtheAssistantvisibleandactive.
WithAssistant
.On=True
.Visible=True
.Left=400
IfNotMoveWhenInTheWayThenMoveWhenInTheWay=True
.Animation=msoAnimationGetAttentionMajor
EndWith
Page 836
NamePropertyReturnsorsetsthenameofthespecifiedobject.Read/writeStringfortheCommandBar,DocumentProperty,andSharedWorkspaceobjects;read-onlyStringforallotherobjects.
Page 837
Remarks
NamepropertyasitappliestotheCommandBarobject.
Thelocalnameofabuilt-incommandbarisdisplayedinthetitlebar(whenthecommandbarisn'tdocked)andinthelistofavailablecommandbars—whereverthatlistisdisplayedinthecontainerapplication.
Forabuilt-incommandbar,theNamepropertyreturnsthecommandbar'sU.S.Englishname.UsetheNameLocalpropertytoreturnthelocalizedname.
IfyouchangethevalueoftheLocalNamepropertyforacustomcommandbar,thevalueofNamechangesaswell,andviceversa.
NamepropertyasitappliestotheSharedWorkspaceMemberobject.
TheNamepropertyoftheSharedWorkspaceMemberobjectreturnsthefriendlynameforthesharedworkspacemember,asspecifiedintheDisplayNameargumentoftheAddmethodoftheSharedWorkspaceMemberscollection.TheSharedWorkspaceMemberobjecthasotherpropertiesthatreturnthemember'sDomainNameorEmail.
Page 838
Example
AsitappliestotheCommandBarobject.
Thisexamplesearchesthecollectionofcommandbarsforthecommandbarnamed"Custom."Ifthiscommandbarisfound,theexamplemakesitvisible.
foundFlag=False
ForEachbarInCommandBars
Ifbar.Name="Custom"Then
foundFlag=True
bar.Visible=True
EndIf
Next
IfNotfoundFlagThen
MsgBox"'Custom'barisn'tincollection."
Else
MsgBox"'Custom'barisnowvisible."
EndIf
AsitappliestotheDocumentPropertyobject.
Thisexampledisplaysthename,type,andvalueofadocumentproperty.YoumustpassavalidDocumentPropertyobjecttotheprocedure.
SubDisplayPropertyInfo(dpAsDocumentProperty)
MsgBox"value="&dp.Value&Chr(13)&_
"type="&dp.Type&Chr(13)&_
"name="&dp.Name
EndSub
Page 840
NameLocalPropertyReturnsthenameofabuilt-incommandbarasit'sdisplayedinthelanguageversionofthecontainerapplication,orreturnsorsetsthenameofacustomcommandbar.Read/writeString.
NoteIfyouattempttosetthispropertyforabuilt-incommandbar,anerroroccurs.
Page 841
Remarks
Thelocalnameofabuilt-incommandbarisdisplayedinthetitlebar(whenthecommandbarisn'tdocked)andinthelistofavailablecommandbars,whereverthatlistisdisplayedinthecontainerapplication.
IfyouchangethevalueoftheLocalNamepropertyforacustomcommandbar,thevalueofNamechangesaswell,andviceversa.
Page 842
Example
Thisexampledisplaysthenameandlocalizednameofthefirstcommandbarinthecontainerapplication.
WithCommandBars(1)
MsgBox"Thenameofthecommandbaris"&.Name
MsgBox"Thelocalizednameofthecommandbaris"&.NameLocal
EndWith
Page 843
NewBalloonPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
CreatesanOfficeAssistantballoon.ReturnsaBalloonobject.Read-only.
Page 844
Example
Thisexamplecreatesaballoonwithaheading,text,andthreeregionchoices,andthendisplaysit.
WithAssistant.NewBalloon
.Heading="RegionalSalesData"
.Text="Selectoneormoreregions"
Fori=1To3
.CheckBoxes(i).Text="Region"&i
Next
.Show
EndWith
Page 845
NotesPropertyReturnsorsetstheoptionalnotesassociatedwithasharedworkspacelink.Read/writeString.
expression.Notes
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceLinkobject.
Thefollowingexamplecreatesalistofallthesharedworkspacelinksthatcontaintheword"building"intheNotesfield.
DimstrBuildingLinksAsString
DimswsLinkAsOffice.SharedWorkspaceLink
ForEachswsLinkInActiveWorkbook.SharedWorkspace.Links
IfInStr(swsLink.Notes,"building",vbTextCompare)>0Then
strBuildingLinks=strBuildingLinks&swsLink.Description&vbCrLf
EndIf
Next
MsgBox"BuildingLinks:"&vbCrLf&strBuildingLinks,_
vbInformation+vbOKOnly,"BuildingLinksinSharedWorkspace"
Page 846
ObjectPropertySetsorreturnstheobjectthatisthebasisforthespecifiedCOMAddInobject.Read/writeObject.
Page 847
Remarks
ThispropertyisprimarilyusedforenablingoneCOMAddIntocommunicatewithanotherCOMAddIn.
Page 848
Example
ThefollowingexamplereturnstheobjectassociatedwiththeCOMaddinmsodraa9.ShapeSelect.
DimobjBaseObjectAsObject
SetobjBaseObject=_
Application.COMAddIns.Item("msodraa9.ShapeSelect")._
Object
Page 850
OLEMenuGroupPropertyReturnsorsetsthemenugroupthatthespecifiedcommandbarpop-upcontrolbelongstowhenthemenugroupsoftheOLEserveraremergedwiththemenugroupsofanOLEclient(thatis,whenanobjectofthecontainerapplicationtypeisembeddedinanotherapplication).Read/writeMsoOLEMenuGroup.
MsoOLEMenuGroupcanbeoneoftheseMsoOLEMenuGroupconstants.msoOLEMenuGroupContainermsoOLEMenuGroupEditmsoOLEMenuGroupFilemsoOLEMenuGroupHelpmsoOLEMenuGroupNonemsoOLEMenuGroupObjectmsoOLEMenuGroupWindow
NoteThispropertyisread-onlyforbuilt-incontrols.
Page 851
Remarks
Thispropertyisintendedtoallowadd-inapplicationstospecifyhowtheircommandbarcontrolswillberepresentedintheOfficeapplication.Ifeitherthecontainerortheserverdoesnotimplementcommandbars,normalOLEmenumergingwilloccur:themenubarwillbemerged,aswellasallthetoolbarsfromtheserver,andnoneofthetoolbarsfromthecontainer.Thispropertyisrelevantonlyforpop-upcontrolsonthemenubarbecausemenusaremergedonthebasisoftheirmenugroupcategory.
Ifbothofthemergingapplicationsimplementcommandbars,commandbarcontrolsaremergedaccordingtotheOLEUsageproperty.
Page 852
Example
ThisexamplecheckstheOLEMenuGrouppropertyofanewcustompop-upcontrolonthecommandbarnamed“Custom”andsetsthepropertytomsoOLEMenuGroupNone.
SetmyControl=CommandBars("Custom").Controls_
.Add(Type:=msoControlPopup,Temporary:=False)
myControl.OLEMenuGroup=msoOLEMenuGroupNone
Page 854
OLEUsagePropertyReturnsorsetstheOLEclientandOLEserverrolesinwhichacommandbarcontrolwillbeusedwhentwoMicrosoftOfficeapplicationsaremerged.Read/writeMsoControlOLEUsage.
MsoControlOLEUsagecanbeoneoftheseMsoControlOLEUsageconstants.msoControlOLEUsageBothmsoControlOLEUsageClientmsoControlOLEUsageNeithermsoControlOLEUsageServer
Page 855
Remarks
Thispropertyisintendedtoallowyoutospecifyhowindividualadd-inapplications'commandbarcontrolswillberepresentedinoneOfficeapplicationwhenitismergedwithanotherOfficeapplication.Ifboththeclientandserverimplementcommandbars,thecommandbarcontrolsareembeddedintheclientcontrolbycontrol.Customcontrolsmarkedasclient-only(orneitherclientnorserver)aredroppedfromtheserver,andcontrolsmarkedasserver-only(orneitherservernorclient)aredroppedfromtheclient.Theremainingcontrolsaremerged.
Ifoneofthemergingapplicationsisn'tanOfficeapplication,normalOLEmenumergingisused,whichiscontrolledbytheOLEMenuGroupproperty.
Page 856
Example
ThisexampleaddsanewbuttontothecommandbarnamedTools,andsetsitsOLEUsageproperty.
SetmyControl=CommandBars("Tools").Controls_
.Add(Type:=msoControlButton,Temporary:=True)
myControl.OLEUsage=msoControlOLEUsageNeither
Page 857
OnPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantisenabled.Read/writeBoolean.
Page 858
Example
ThisexampledisablestheOfficeAssistant,displaysamessageboxthataskstheuserwhethertheAssistantshouldbeenabled,andenablestheAssistantiftheuserclicksYes.IftheusersenablestheAssistant,theAssistantappearsandperformstheanimationmsoAnimationGreeting.
Assistant.On=False
IfMsgBox("EnableOfficeAssistant?",_
vbYesNo,"AssistantisOff")=vbYesThen
Assistant.On=True
Assistant.Visible=True
Assistant.Animation=_
msoAnimationGetAttentionMajor
EndIf
Page 860
OnActionPropertyReturnsorsetsthenameofaVisualBasicprocedurethatwillrunwhentheuserclicksorchangesthevalueofacommandbarcontrol.Read/writeString.
NoteThecontainerapplicationdetermineswhetherthevalueisavalidmacroname.
Page 861
Example
Thisexampleaddsacommandbarcontroltothecommandbarnamed"Custom".Theprocedurenamed"MySub"willruneachtimethecontrolisclicked.
SetmyBar=CommandBars("Custom")
SetmyControl=myBar.Controls_
.Add(Type:=msocontrolButton)
WithmyControl
.FaceId=2
.OnAction="MySub"
EndWith
myBar.Visible=True
Thisexampleaddsacommandbarcontroltothecommandbarnamed"Custom".TheCOMaddinnamed"FinanceAddIn"willruneachtimethecontrolisclicked.
SetmyBar=CommandBars("Custom")
SetmyControl=myBar.Controls_
.Add(Type:=msocontrolButton)
WithmyControl
.FaceId=2
.OnAction="!<FinanceAddIn>"
EndWith
myBar.Visible=True
Page 862
ParameterPropertyReturnsorsetsastringthatanapplicationcanusetoexecuteacommand.Read/writeString.
Page 863
Remarks
Ifthespecifiedparameterissetforabuilt-incontrol,theapplicationcanmodifyitsdefaultbehaviorifitcanparseandusethenewvalue.Iftheparameterissetforcustomcontrols,itcanbeusedtosendinformationtoVisualBasicprocedures,oritcanbeusedtoholdinformationaboutthecontrol(similartoasecondTagpropertyvalue).
Page 864
Example
Thisexampleassignsanewparametertoacontrolandsetsthefocustothenewbutton.
SetmyControl=CommandBars("Custom").Controls(4)
WithmyControl
.Copy,1
.Parameter="2"
.SetFocus
EndWith
Page 865
ParentPropertyReturnstheParentobjectforthespecifiedobject.Read-only.
Page 866
Example
Thisexampledisplaysthenameoftheparentobjectforadocumentproperty.YoumustpassavalidDocumentPropertyobjecttotheprocedure.
SubDisplayParent(dpasDocumentProperty)
MsgBoxdp.Parent.Name
EndSub
Page 867
PathPropertyReturnsaStringindicatingthefullpathofaScopeFolderobject.Read-only.
expression.Path
expressionRequired.AnexpressionthatreturnsaScopeFolderobject.
Page 868
Example
ThefollowingexampledisplaystherootpathofeachdirectoryinMyComputer.Toretrievethisinformation,theexamplefirstgetstheScopeFolderobjectattherootofMyComputer.ThepathofthisScopeFolderwillalwaysbe"*".AswithallScopeFolderobjects,therootobjectcontainsaScopeFolderscollection.ThisexampleloopsthroughthisScopeFolderscollectionanddisplaysthepathofeachScopeFolderobjectinit.ThepathsoftheseScopeFolderobjectswillbe"A:\","C:\",etc.
SubDisplayRootScopeFolders()
'Declarevariablesthatreferencea
'SearchScopeandaScopeFolderobject.
DimssAsSearchScope
DimsfAsScopeFolder
'UseaWith...EndWithblocktoreferencethe
'FileSearchobject.
WithApplication.FileSearch
'LoopthroughtheSearchScopescollection
'anddisplayalloftherootScopeFolderscollectionsin
'theMyComputerscope.
ForEachssIn.SearchScopes
SelectCasess.Type
CasemsoSearchInMyComputer
'LoopthrougheachScopeFoldercollectionsin
'theScopeFolderscollectionofthe
'SearchScopeobjectanddisplaythepath.
ForEachsfInss.ScopeFolder.ScopeFolders
MsgBox"Path:"&sf.Path
Nextsf
CaseElse
EndSelect
Nextss
EndWith
EndSub
Page 871
PermissionPropertyReturnsorsetsaLongvaluerepresentingthepermissionsontheactivedocumentassignedtotheuserassociatedwiththespecifiedUserPermissionobject.Read/writeLong.ThePermissionpropertycanbeoneoracombinationofMsoPermissionconstants.
MsoPermissioncanbeoneofthefollowingmsoPermissionconstants.msoPermissionView(1)msoPermissionRead(1)msoPermissionEdit(2)msoPermissionSave(4)msoPermissionExtract(8)msoPermissionChange(15)msoPermissionPrint(16)msoPermissionObjectModel(32)msoPermissionFullControl(64)
expression.Permission
expressionRequired.AnexpressionthatreturnsaUserPermissionobject.
Page 872
Remarks
TheUserPermissionobjectassociatesasetofpermissionsontheactivedocumentwithasingleuserandanoptionalexpirationdate.ThePermissionpropertyreturnsthesetofuserpermissionsdeterminedbythespecifiedUserPermissionobject.Whilesomepermissionsgrantedthroughtheuserinterface(suchasmsoPermissionPrint)applytoallusers,youcanusetheUserPermissionobjecttoassignthemonaper-userbasiswithper-userexpirationdates.
ThemsoPermissionViewormsoPermissionReadoptioncorrespondstotheRead...optionintheuserinterface.ThemsoPermissionExtractoptioncorrespondstotheAllowuserswithreadaccesstocopycontentoptionintheuserinterface.ThemsoPermissionChangeoptioncorrespondstotheChange...optionintheuserinterface.ThemsoPermissionChangeoptionrepresentsthesumofmsoPermissionView+msoPermissionEdit+msoPermissionSave+msoPermissionExtractandallowsuserstoview,edit,copy,andsave,butnotprint,thedocument.ThemsoPermissionPrintoptioncorrespondstothePrintcontentoptionintheuserinterface.ThemsoPermissionObjectModeloptioncorrespondstotheAccesscontentprogrammaticallyoptionintheuserinterfaceandallowsuserstoaccessthedocumentprogrammaticallythroughitsobjectmodel.UserswithoutmsoPermissionObjectModelcannotusetheobjectmodeltodeterminetheirownrights,sinceprogrammaticaccessisdisabled.
Page 873
Example
ThefollowingexampleusesthebitwiseAndoperatorwiththePermissionpropertyandanmsoPermissionconstanttodeterminewhethertheseconduserhaspermissiontosavetheactivedocument.
DimirmPermissionAsOffice.Permission
DimirmUserPermAsOffice.UserPermission
SetirmPermission=ActiveWorkbook.Permission
SetirmUserPerm=irmPermission.Item(2)
IfirmUserPerm.PermissionAndOffice.msoPermissionSaveThen
MsgBox"User"&irmUserPerm.UserId&_
"haspermissiontosavethisdocument.",_
vbInformation+vbOKOnly,"IRMInformation"
Else
MsgBox"User"&irmUserPerm.UserId&_
"doesNOThavepermissiontosavethisdocument.",_
vbInformation+vbOKOnly,"IRMInformation"
EndIf
SetirmUserPerm=Nothing
SetirmPermission=Nothing
Page 874
PermissionFromPolicyPropertyReturnsaBooleanvaluethatindicateswhetherapermissionpolicyhasbeenappliedtotheactivedocument.Read-onlyBoolean.
expression.PermissionFromPolicy
expressionRequired.AnexpressionthatreturnsaPermissionobject.
Page 875
Remarks
MicrosoftOffice2003InformationRightsManagementsupportstheuseofadministrativepermissionpolicieswhichlistusersandgroupsandtheirdocumentpermissions.ThePermissionFromPolicypropertyreturnsaBooleanvaluethatindicateswhetherapermissionpolicywasappliedtotheactivedocumentthelasttimepermissionswereenabledonthedocument.
ThePermissionFromPolicypropertyalwaysreturnsFalsewhencheckedbyanon-ownerofthedocument,evenwhentheuserhasobjectmodelpermissions.
Page 876
Example
Thefollowingexampledisplayspermissionpolicyinformationabouttheactivedocument.
DimirmPermissionAsOffice.Permission
DimstrIRMInfoAsString
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
strIRMInfo="Permissionsarerestrictedonthisdocument."&vbCrLf
IfirmPermission.PermissionFromPolicyThen
strIRMInfo=strIRMInfo&"Permissionsappliedfrompolicy:"&vbCrLf&_
"Policyname:"&irmPermission.PolicyName&vbCrLf&_
"Policydescription:"&irmPermission.PolicyDescription
Else
strIRMInfo=strIRMInfo&"Defaultpermissionsapplied."&vbCrLf&_
"Defaultpolicyname:"&irmPermission.PolicyName&vbCrLf&_
"Defaultpolicydescription:"&irmPermission.PolicyDescription
EndIf
Else
strIRMInfo="PermissionareNOTrestrictedonthisdocument."
EndIf
MsgBoxstrIRMInfo,vbInformation+vbOKOnly,"IRMInformation"
SetirmPermission=Nothing
Page 877
PicturePropertyReturnsanIPictureDispobjectrepresentingtheimageofaCommandBarButtonobject.
expression.Picture
expressionRequired.AnexpressionthatreturnsaCommandBarButtonobject.
Page 878
Remarks
Whenyouchangetheimageonabutton,youwillalsowanttousetheMaskpropertytosetamaskimage.Themaskimagedetermineswhichpartsofthebuttonimagearetransparent.AlwayssetthemaskafteryouhavesetthepictureforaCommandBarButtonobject.
NoteTheimagesfortheViewMicrosoftApplicationandInsertItembuttonsontheStandardtoolbarintheVisualBasicEditorcannotbechanged.
Page 879
Example
ThefollowingexamplesetstheimageandmaskofthefirstCommandBarButtonthatthecodereturns.Tomakethiswork,createamaskimageandabuttonimageandsubstitutethepathsinthesamplewiththepathstoyourimages.
SubChangeButtonImage()
DimpicPictureAsIPictureDisp
DimpicMaskAsIPictureDisp
SetpicPicture=stdole.StdFunctions.LoadPicture(_
"c:\images\picture.bmp")
SetpicMask=stdole.StdFunctions.LoadPicture(_
"c:\images\mask.bmp")
'Referencethefirstbuttononthefirstcommandbar
'usingaWith...EndWithblock.
WithApplication.CommandBars.FindControl(msoControlButton)
'Changethebuttonimage.
.Picture=picPicture
'Usethesecondimagetodefinetheareaofthe
'buttonthatshouldbetransparent.
.Mask=picMask
EndWith
EndSub
ThefollowingexamplegetstheimageandmaskofthefirstCommandBarButtonthatthecodereturnsandoutputseachofthemtoafile.Tomakethiswork,specifyapathfortheoutputfiles.
SubGetButtonImageAndMask()
DimpicPictureAsIPictureDisp
DimpicMaskAsIPictureDisp
WithApplication.CommandBars.FindControl(msoControlButton)
'GetthebuttonimageandmaskofthisCommandBarButtonobject.
SetpicPicture=.Picture
SetpicMask=.Mask
EndWith
'Savethebuttonimageandmaskinafolder.
stdole.SavePicturepicPicture,"c:\image.bmp"
Page 880
stdole.SavePicturepicMask,"c:\mask.bmp"
EndSub
Page 881
PolicyDescriptionPropertyReturnsthedescriptionofthepermissionspolicyappliedtotheactivedocument.Read-onlyString.
expression.PolicyDescription()
expressionRequired.AnexpressionthatreturnsaPermissionobject.
Page 882
Remarks
MicrosoftOfficeInformationRightsManagementsupportstheuseofadministrativepermissionpolicieswhichlistusersandgroupsandtheirdocumentpermissions.ThePolicyDescriptionpropertyreturnsthedescriptionofthepolicyappliedtotheactivedocument,oradefaultvalueifapolicywasnotused.
Page 883
Example
Thefollowingexampledisplayspermissionpolicyinformationabouttheactivedocument.
DimirmPermissionAsOffice.Permission
DimstrIRMInfoAsString
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
strIRMInfo="Permissionsarerestrictedonthisdocument."&vbCrLf
IfirmPermission.PermissionFromPolicyThen
strIRMInfo=strIRMInfo&"Permissionsappliedfrompolicy:"&vbCrLf&_
"Policyname:"&irmPermission.PolicyName&vbCrLf&_
"Policydescription:"&irmPermission.PolicyDescription
Else
strIRMInfo=strIRMInfo&"Defaultpermissionsapplied."&vbCrLf&_
"Defaultpolicyname:"&irmPermission.PolicyName&vbCrLf&_
"Defaultpolicydescription:"&irmPermission.PolicyDescription
EndIf
Else
strIRMInfo="PermissionareNOTrestrictedonthisdocument."
EndIf
MsgBoxstrIRMInfo,vbInformation+vbOKOnly,"IRMInformation"
SetirmPermission=Nothing
Page 884
PolicyNamePropertyReturnsthenameofthepermissionspolicyappliedtotheactivedocument.Read-onlyString.
expression.PolicyName
expressionRequired.AnexpressionthatreturnsaPermissionobject.
Page 885
Remarks
MicrosoftOfficeInformationRightsManagementsupportstheuseofadministrativepermissionpolicieswhichlistusersandgroupsandtheirdocumentpermissions.ThePolicyNamepropertyreturnsthenameofthepolicyappliedtotheactivedocument,oradefaultvalueifapolicywasnotused.
Page 886
Example
Thefollowingexampledisplayspermissionpolicyinformationabouttheactivedocument.
DimirmPermissionAsOffice.Permission
DimstrIRMInfoAsString
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
strIRMInfo="Permissionsarerestrictedonthisdocument."&vbCrLf
IfirmPermission.PermissionFromPolicyThen
strIRMInfo=strIRMInfo&"Permissionsappliedfrompolicy:"&vbCrLf&_
"Policyname:"&irmPermission.PolicyName&vbCrLf&_
"Policydescription:"&irmPermission.PolicyDescription
Else
strIRMInfo=strIRMInfo&"Defaultpermissionsapplied."&vbCrLf&_
"Defaultpolicyname:"&irmPermission.PolicyName&vbCrLf&_
"Defaultpolicydescription:"&irmPermission.PolicyDescription
EndIf
Else
strIRMInfo="PermissionareNOTrestrictedonthisdocument."
EndIf
MsgBoxstrIRMInfo,vbInformation+vbOKOnly,"IRMInformation"
SetirmPermission=Nothing
Page 888
PositionPropertyReturnsorsetsthepositionofacommandbar.Read/writeMsoBarPosition.
MsoBarPositioncanbeoneoftheseMsoBarPositionconstants.msoBarBottommsoBarFloatingmsoBarLeftmsoBarMenuBarmsoBarPopupmsoBarRightmsoBarTop
Page 889
Example
Thisexamplestepsthroughthecollectionofcommandbars,dockingthecustomcommandbarsatthebottomoftheapplicationwindowanddockingthebuilt-incommandbarsatthetopofthewindow.
ForEachbarInCommandBars
Ifbar.Visible=TrueThen
Ifbar.BuiltInThen
bar.Position=msoBarTop
Else
bar.Position=msoBarBottom
EndIf
EndIf
Next
Page 891
PriorityPropertyAsitappliestotheCommandBarButton,CommandBarComboBox,
andCommandBarControlobjects.
Returnsorsetsthepriorityofacommandbarcontrol.Acontrol'sprioritydetermineswhetherthecontrolcanbedroppedfromadockedcommandbarifthecommandbarcontrolscan'tfitinasinglerow.Controlsthatcan'tfitinasinglerowdropoffcommandbarsfromrighttoleft.Read/writeLong.
Page 892
Remarks
Validprioritynumbersare0(zero)through7andthedefaultvalueis3.Apriorityof1meansthatthecontrolcannotbedroppedfromatoolbar.Otherpriorityvaluesareignored.
ThePrioritypropertyisnotusedbycommandbarcontrolsthataremenuitems.
AsitappliestotheSharedWorkspaceTaskobject.
Returnsorsetsthestatusofthespecifiedsharedworkspacetask.Read/writemsoSharedWorkspaceTaskPriority.
MsoSharedWorkspaceTaskPrioritycanbeoneofthefollowingmsoSharedWorkspaceTaskPriorityconstants.msoSharedWorkspaceTaskPriorityHigh(1)msoSharedWorkspaceTaskPriorityLow(3)msoSharedWorkspaceTaskPriorityNormal(2)
expression.Priority
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceTaskobject.
Page 893
Remarks
Thesharedworkspacetaskschemaontheservercanbecustomized.CustomizationoftheschemamayaffectthetaskpriorityenumerationwhentheAddorSavemethodiscalled.Prioritypropertyvaluesaremappedasfollows:
Downloadedvalue1ismappedtomsoSharedWorkspaceTaskPriority1(msoSharedWorkspaceTaskPriorityHigh).Downloadedvalues2throughN-1aremappedtomsoSharedWorkspaceTaskPriority2(msoSharedWorkspaceTaskPriorityNormal).DownloadedvalueNismappedtomsoSharedWorkspaceTaskPriority3(msoSharedWorkspaceTaskPriorityLow).Uploadedenumerationvalues1through3aremappedtoschemavalues1through3.Ifauser-specifiedvaluedoesnotmaptoanyvaluedefinedintheschema,theuser-specifiedvalueissilentlyignoredandtheStatuspropertyisnotupdatedontheserver.
Page 894
Example
AsitappliestotheCommandBarButton,CommandBarComboBox,andCommandBarControlobject.
Thisexamplemovesacontrolandassignsitapriorityof5sothatitwilllikelybedroppedfromthecommandbarifthecontrolsdon'tallfitinonerow.
Setallcontrols=CommandBars("Custom").Controls
ForEachctrlInallControls
Ifctrl.Type=msoControlComboBoxThen
Withctrl
.MoveBefore:=7
.Tag="Selectionbox"
.Priority=5
EndWith
ExitFor
EndIf
Next
AsitappliestotheSharedWorkspaceTaskobject.
Thefollowingexampleraisesthepriorityofeachtaskinthesharedworkspacebyonestep,unlessthetaskpriorityisalreadysettoHigh,anduploadsthechangestotheserver.(Highpriorityisthelowestvalueintheenumeration.)
DimswsTaskAsOffice.SharedWorkspaceTask
DimlngTaskPriorityAsMsoSharedWorkspaceTaskPriority
ForEachswsTaskInActiveWorkbook.SharedWorkspace.Tasks
lngTaskPriority=swsTask.Priority
IflngTaskPriority>msoSharedWorkspaceTaskPriorityHighThen
swsTask.Priority=lngTaskPriority-1
swsTask.Save
EndIf
Next
SetswsTask=Nothing
Page 896
PrivatePropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ReturnsorsetsanintegerthatidentifiestheOfficeAssistantballoonthatinitiatedthecallbackprocedure.Read/writeLong.
Page 897
Remarks
Thispropertyishelpfulifyourunthesamecallbackprocedurefrommorethanoneballoon.
Page 898
Example
ThisexampleidentifiestheOfficeAssistantballoonbysettingthePrivatepropertyto129.
SetprinterOrientation=Assistant.NewBalloon
WithprinterOrientation.Heading="Printportraitorlandscape?"
.Text="ClickOKwhenyou'veselectedthe"&_
"printerorientation."
.Labels(1).Text="Portrait"
.Labels(2).Text="Landscape"
.BalloonType=msoBalloonTypeButtons
.Mode=msoModeModeless
.Button=msoButtonSetOK
.Private=129
.Callback="PortraitOrLandscape"
.Show
EndWith
Page 899
ProgIdPropertyReturnstheprogrammaticidentifier(ProgID)forthespecifiedCOMAddInobject.Read-onlyString.
Page 900
Example
ThefollowingexampledisplaystheProgIDandGUIDforCOMadd-inoneinamessagebox.
MsgBox"MyProgIDis"&_
Application.COMAddIns(1).ProgID&_
"andmyGUIDis"&_
Application.COMAddIns(1).Guid
Page 901
PropertyTestsPropertyReturnsthePropertyTestscollectionthatrepresentsallthesearchcriteriaforafilesearch.Read-only.
Forinformationaboutreturningasinglememberofacollection,seeReturninganObjectfromaCollection.
Page 902
Example
Thisexampledisplaysallthesearchcriteriaforthefirstpropertytestinthecollection.
WithApplication.FileSearch.PropertyTests(1)
myString="Thisisthesearchcriteria:"_
&"Thenameis:"&.Name&".Theconditionis:"_
&.Condition
If.Value<>""Then
myString=myString&".Thevalueis:"&.Value
If.SecondValue<>""Then
myString=myString_
&".Thesecondvalueis:"_
&.SecondValue&",andtheconnectoris"_
&.Connector
EndIf
EndIf
MsgBoxmyString
EndWith
Page 903
ProportionalFontPropertySetsorreturnstheproportionalfontsettinginthehostapplication.Read/writeString.
Page 904
Remarks
WhenyousettheProportionalFontproperty,thehostapplicationdoesnotcheckthevalueforvalidity.
Page 905
Example
ThisexamplesetstheproportionalfontandproportionalfontsizefortheEnglish/WesternEuropean/OtherLatinScriptcharactersetintheactiveapplication.
Application.DefaultWebOptions._
Fonts(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)_
.ProportionalFont="Tahoma"
Application.DefaultWebOptions._
Fonts(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)_
.ProportionalFontSize=14.5
Page 906
ProportionalFontSizePropertySetsorreturnstheproportionalfontsizesettinginthehostapplication,inpoints.Read/writeSingle.
Page 907
Remarks
WhenyousettheProportionalFontSizeproperty,thehostapplicationdoesnotcheckthevalueforvalidity.Ifyouenteraninvalidvalue,suchasanonnumber,thehostapplicationsetsthesizeto0points.Youcanenterhalf-pointsizes;ifyouenterotherfractionalpointsizes,theyareroundedupordowntothenearesthalf-point.
Page 908
Example
ThisexamplesetstheproportionalfontandproportionalfontsizefortheEnglish/WesternEuropean/OtherLatinScriptcharactersetintheactiveapplication.
Application.DefaultWebOptions._
Fonts(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)_
.ProportionalFont="Tahoma"
Application.DefaultWebOptions._
Fonts(msoCharacterSetEnglishWesternEuropeanOtherLatinScript)_
.ProportionalFontSize=14.5
Page 910
ProtectionPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
Returnsorsetsthewayacommandbarisprotectedfromusercustomization.Read/writeMsoBarProtection.
MsoBarProtectioncanbeoneoftheseMsoBarProtectionconstants.msoBarNoChangeDockmsoBarNoChangeVisiblemsoBarNoCustomizemsoBarNoHorizontalDockmsoBarNoMovemsoBarNoProtectionmsoBarNoResizemsoBarNoVerticalDock
Page 911
Remarks
UsingtheconstantmsoBarNoCustomizepreventsusersfromaccessingtheAddorRemoveButtonsmenu(thismenuenablesuserstocustomizeatoolbar).
Page 912
Example
Thisexamplestepsthroughthecollectionofcommandbarstofindthecommandbarnamed"Forms."Ifthiscommandbarisfound,it'sdockingstateisprotectedandit'smadevisible.
foundFlag=False
Fori=1ToCommandBars.Count
IfCommandBars(i).Name="Forms"Then
CommandBars(i).Protection=msoBarNoChangeDock
CommandBars(i).Visible=True
foundFlag=True
EndIf
Next
IfNotfoundFlagThen
MsgBox"'Forms'commandbarisnotinthecollection."
EndIf
Page 913
ReducedPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantwindowappearsinitssmallersize.Read/writeBoolean.
Page 914
Remarks
ThispropertyisnotusedinMicrosoftOffice.
Page 915
Example
ThisexampledisplaystheOfficeAssistantinaspecificlocationanditsetsseveraloptionsbeforemakingtheAssistantvisible.
WithAssistant
.Reduced=True
.Left=400
.MoveWhenInTheWay=True
.TipOfDay=True
.Visible=True
.Animation=msoAnimationGreeting
EndWith
Page 916
RequestPermissionURLPropertyReturnsorsetsthefileorwebsiteURLtovisitortheemailaddresstocontactforuserswhoneedadditionalpermissionsontheactivedocument.Read/writeString.
expression.RequestPermissionURL
expressionRequired.AnexpressionthatreturnsaPermissionobject.
Page 917
Remarks
TheRequestPermissionURLsettingcorrespondstotheUserscanrequestadditionalpermissionsfromoptioninthepermissionsuserinterface.UsetheRequestPermissionURLpropertytospecifyafile,awebsite,oranemailcontactfromwhichuserscanrequest,orlearnhowtorequest,additionalpermissionsontheactivedocument,forexample:
Awebaddress:http://companyserver/request_permissions.aspAfile:\\companyserver\share\requesting_permissions.txtAnemailaddress:mailto:[email protected] ?Subject=Request%20permissions
Page 918
Example
Thefollowingexampledisplaysinformationaboutthepermissionssettingsoftheactivedocument,includingtheRequestPermissionURLsetting.
DimirmPermissionAsOffice.Permission
DimstrIRMInfoAsString
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
strIRMInfo="Permissionsarerestrictedonthisdocument."&vbCrLf
strIRMInfo=strIRMInfo&"Viewintrustedbrowser:"&_
irmPermission.EnableTrustedBrowser&vbCrLf&_
"Documentauthor:"&irmPermission.DocumentAuthor&vbCrLf&_
"Userswithpermissions:"&irmPermission.Count&vbCrLf&_
"Cachelicenseslocally:"&irmPermission.StoreLicenses&vbCrLf&_
"RequestpermissionURL:"&irmPermission.RequestPermissionURL&vbCrLf
IfirmPermission.PermissionFromPolicyThen
strIRMInfo=strIRMInfo&"Permissionsappliedfrompolicy:"&vbCrLf&_
"Policyname:"&irmPermission.PolicyName&vbCrLf&_
"Policydescription:"&irmPermission.PolicyDescription
Else
strIRMInfo=strIRMInfo&"Defaultpermissionsapplied."
EndIf
Else
strIRMInfo="PermissionsareNOTrestrictedonthisdocument."
EndIf
MsgBoxstrIRMInfo,vbInformation+vbOKOnly,"IRMInformation"
SetirmPermission=Nothing
Page 919
RowCountPropertyReturnsaLongthatrepresentsthenumberofrecordsinthespecifieddatasource.Read-only.
expression.RowCount
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 920
Example
ThisexampleaddsanewfilterthatremovesallrecordswithablankRegionfieldandthenappliesthefiltertotheactivepublication.
SubOfficeFilters()
DimappOfficeAsOfficeDataSourceObject
DimappFiltersAsODSOFilters
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
SetappFilters=appOffice.Filters
MsgBoxappOffice.RowCount
appFilters.AddColumn:="Region",Comparison:=msoFilterComparisonEqual,_
Conjunction:=msoFilterConjunctionAnd,bstrCompareTo:="WA"
appOffice.ApplyFilter
MsgBoxappOffice.RowCount
EndSub
Page 922
RowIndexPropertyReturnsorsetsthedockingorderofacommandbarinrelationtoothercommandbarsinthesamedockingarea.Canbeanintegergreaterthanzero,oreitherofthefollowingMsoBarRowconstants:msoBarRowFirstormsoBarRowLast.Read/writeLong.
Page 923
Remarks
Severalcommandbarscansharethesamerowindex,andcommandbarswithlowernumbersaredockedfirst.Iftwoormorecommandbarssharethesamerowindex,thecommandbarmostrecentlyassignedwillbedisplayedfirstinitsgroup.
Page 924
Example
Thisexampleadjuststhepositionofthecommandbarnamed"Custom"bymovingittotheleft110pixelsmorethanthedefault,anditmakesthiscommandbarthefirsttobedockedbychangingitsrowindextomsoBarRowFirst.
SetmyBar=CommandBars("Custom")
WithmyBar
.RowIndex=msoBarRowFirst
.Left=140
EndWith
Page 925
UnsupportedLanguageElementYouhaverequestedHelpforalanguageelementthatisnotsupported.
Page 926
ScopeFolderPropertyReturnsaScopeFolderobject.
expression.ScopeFolder
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 927
Example
ThefollowingexampledisplaystherootpathofeachdirectoryinMyComputer.Toretrievethisinformation,theexamplefirstgetstheScopeFolderobjectattherootofMyComputer.ThepathofthisScopeFolderwillalwaysbe"*".AswithallScopeFolderobjects,therootobjectcontainsaScopeFolderscollection.ThisexampleloopsthroughthisScopeFolderscollectionanddisplaysthepathofeachScopeFolderobjectinit.ThepathsoftheseScopeFolderobjectswillbe"A:\","C:\",etc.
SubDisplayRootScopeFolders()
'Declarevariablesthatreferencea
'SearchScopeandaScopeFolderobject.
DimssAsSearchScope
DimsfAsScopeFolder
'UseaWith...EndWithblocktoreferencethe
'FileSearchobject.
WithApplication.FileSearch
'LoopthroughtheSearchScopescollection
'anddisplayalloftherootScopeFolderscollectionsin
'theMyComputerscope.
ForEachssIn.SearchScopes
SelectCasess.Type
CasemsoSearchInMyComputer
'LoopthrougheachScopeFolderobjectin
'theScopeFolderscollectionofthe
'SearchScopeobjectanddisplaythepath.
ForEachsfInss.ScopeFolder.ScopeFolders
MsgBox"Path:"&sf.Path
Nextsf
CaseElse
EndSelect
Nextss
EndWith
EndSub
Page 929
ScopeFoldersPropertyReturnsaScopeFolderscollection.TheitemsinthiscollectioncorrespondtothesubfoldersoftheparentScopeFolderobject.
expression.ScopeFolders
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 930
Example
ThefollowingexampledisplaystherootpathofeachdirectoryinMyComputer.Toretrievethisinformation,theexamplefirstgetstheScopeFolderobjectattherootofMyComputer.ThepathofthisScopeFolderwillalwaysbe"*".AswithallScopeFolderobjects,therootobjectcontainsaScopeFolderscollection.ThisexampleloopsthroughthisScopeFolderscollectionanddisplaysthepathofeachScopeFolderobjectinit.ThepathsoftheseScopeFolderobjectswillbe"A:\","C:\",etc.
SubDisplayRootScopeFolders()
'Declarevariablesthatreferencea
'SearchScopeandaScopeFolderobject.
DimssAsSearchScope
DimsfAsScopeFolder
'UseaWith...EndWithblocktoreferencethe
'FileSearchobject.
WithApplication.FileSearch
'LoopthroughtheSearchScopescollection
'anddisplayalloftherootScopeFolderscollectionsin
'theMyComputerscope.
ForEachssIn.SearchScopes
SelectCasess.Type
CasemsoSearchInMyComputer
'LoopthrougheachScopeFolderobjectin
'theScopeFolderscollectionofthe
'SearchScopeobjectanddisplaythepath.
ForEachsfInss.ScopeFolder.ScopeFolders
MsgBox"Path:"&sf.Path
Nextsf
CaseElse
EndSelect
Nextbss
EndWith
EndSub
Page 932
ScriptTextPropertySetsorreturnsthetextcontainedinablockofscript.Read/writeString.
Page 933
Remarks
TheMicrosoftOfficehostapplicationdoesn’tcheckthesyntaxofthescript.TheScriptTextpropertyisthedefaultpropertyfortheScriptobject.
Page 934
Example
Thisexamplesetsthetextofthefirstscriptinworksheetoneintheactiveworkbook.
ActiveWorkbook.Worksheets(1).Scripts(1).ScriptText=_
"MsgBox""NewScriptText"""
Page 935
SearchFoldersPropertyReturnsaSearchFolderscollection.
expression.SearchFolders
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 936
Example
ThefollowingexampledisplaysthecurrentnumberofScopeFolderobjectsintheSearchFolderscollection.SeetheSearchFolderscollectiontopicforamoredetailedexample.
MsgBox"NumberofScopeFolderobjectsintheSearchFolderscollection:"&_
Application.FileSearch.SearchFolders.Count
Page 937
SearchScopesPropertyReturnsaSearchScopescollection.
expression.SearchScopes
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 938
Example
ThefollowingexampledisplaysallofthecurrentlyavailableSearchScopeobjectsintheSearchScopescollection.
SubDisplayAvailableScopes()
'Declareavariablethatreferencesa
'SearchScopeobject.
DimssAsSearchScope
'UseaWith...EndWithblocktoreferencethe
'FileSearchobject.
WithApplication.FileSearch
'LoopthroughtheSearchScopescollection
ForEachssIn.SearchScopes
SelectCasess.Type
CasemsoSearchInMyComputer
MsgBox"MyComputerisanavailablesearchscope."
CasemsoSearchInMyNetworkPlaces
MsgBox"MyNetworkPlacesisanavailablesearchscope."
CasemsoSearchInOutlook
MsgBox"Outlookisanavailablesearchscope."
CasemsoSearchInCustom
MsgBox"Acustomsearchscopeisavailable."
CaseElse
MsgBox"Can'tdeterminesearchscope."
EndSelect
Nextss
EndWith
EndSub
Page 939
SearchSubFoldersPropertyTrueifthesearchincludesallthesubfoldersinthefolderspecifiedbytheLookInproperty.Read/writeBoolean.
Page 940
Example
ThisexamplesearchestheMyDocumentsfolderandallofitssubfoldersforallfileswhosenamesbeginwith"Cmd."Theexamplealsodisplaysthenameandlocationofeachfilethat'sfound.
Setfs=Application.FileSearch
Withfs
.LookIn="C:\MyDocuments"
.SearchSubFolders=True
.FileName="cmd*"
If.Execute()>0Then
MsgBox"Therewere"&.FoundFiles.Count&_
"file(s)found."
Fori=1To.FoundFiles.Count
MsgBox.FoundFiles(i)
Nexti
Else
MsgBox"Therewerenofilesfound."
EndIf
EndWith
Page 941
SearchWhenProgrammingPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantdisplaysapplicationandprogrammingHelpwhiletheuserisworkinginVisualBasic.Read/writeBoolean.
Page 942
Remarks
ThedefaultvalueisFalse.SearchWhenProgrammingpropertycorrespondstotheSearchforbothproductandprogramminghelpwhenprogrammingoptionintheUsetheOfficeAssistantsectionontheOptionstabintheOfficeAssistantdialogbox.
Page 943
Example
ThisexampleallowstheusertosearchbothapplicationandprogramminghelpwhileworkinginVisualBasic.
Assistant.SearchWhenProgramming=True
Page 944
SecondValuePropertyReturnsanoptionalsecondvaluepropertytest(asinarange)forthefilesearch.Read-onlyVariant.
Page 945
Remarks
Thispropertyisintendedtobeusedtospecifyarange,anditcanonlybeusedwiththeMsoConditionconstantmsoConditionAnyTimeBetweenormsoConditionAnyNumberBetween.
Page 946
Example
Thisexampledisplaysthesecondvalueofthesearchcriteria(ifitexists)inadialogbox.Ifthesecondvaluedoesn'texist,theexampledisplaysanothermessage.
WithApplication.FileSearch.PropertyTests(1)
If.SecondValue=""Then
MsgBox"Youhaven'tspecifiedasecondvalue."
Else
MsgBox"Thesecondvalueyou'vesetis:"_
&.SecondValue
EndIf
EndWith
Page 947
SelectedItemsPropertyReturnsaFileDialogSelectedItemscollection.ThiscollectioncontainsalistofthepathsofthefilesthatauserselectedfromafiledialogboxdisplayedusingtheShowmethodoftheFileDialogobject.
expression.SelectedItems
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 948
Example
ThefollowingexampledisplaysaFilePickerdialogboxusingtheFileDialogobjectanddisplayseachselectedfileinamessagebox.
SubMain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'Allowtheusertoselectmultiplefiles.
.AllowMultiSelect=True
'UsetheShowmethodtodisplaytheFilePickerdialogboxandreturntheuser'saction.
'Iftheuserpressestheactionbutton...
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Selecteditem'spath:"&vrtSelectedItem
Next
'IftheuserpressesCancel...
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Setfd=Nothing
EndSub
Page 950
ShapePropertyReturnsaShapeobjectorInlineShapeobject,dependingontheMicrosoftOfficehostapplication.Read-onlyObject.
Page 951
Remarks
TheShapepropertyreturnsaShapeobjectinMicrosoftExcelandPowerPoint.InWord,theShapepropertyreturnsaShapeobjectifthescriptanchorisfloating;ifit’saninlineanchor,however,thispropertyreturnsanInlineShapeobject.
Page 952
Example
ThisexamplegetstheshapeassociatedwiththefirstscriptintheScriptscollectionanddeletesitfromworksheetoneintheactiveworkbook.
DimobjScriptShapeAsObject
SetobjScriptShape=_
ActiveWorkbook.Worksheets(1).Scripts(1).Shape
ObjScriptShape.Delete
Page 954
ShortcutTextPropertyReturnsorsetstheshortcutkeytextdisplayednexttoabuttoncontrolwhenthebuttonappearsonamenu,submenu,orshortcutmenu.Read/writeString.
Page 955
Remarks
YoucansetthispropertyonlyforcommandbarbuttonsthatcontainanOnActionmacro.
Page 956
Example
ThisexampledisplaystheshortcuttextfortheOpencommand(Filemenu)ontheMicrosoftExcelWorksheetmenubarinamessagebox.
MsgBox(CommandBars("WorksheetMenuBar")._
Controls("File").Controls("New...).ShortcutText)
Page 957
SignDatePropertyReturnsaVariantrepresentingthedateandtimethatthedigitalcertificatecorrespondingtotheSignatureobjectwasattachedtothedocument.Read-only.
expression.SignDate
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 958
Example
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandcallthisfunction.Thefunctionwilltesttomakesurethatthedigitalsignaturethattheuserselectswillnotexpireinlessthan12months.Ifitwillexpire,thecertificateisn'tattached.
FunctionAddSignature()AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
'TesttomakesurethatthenewSignatureobject
'doesn'texpiretoosoon.Thisexpressioncalculates
'thenumberofmonthsuntiltheSignatureobjectexpires.
IfDateDiff("m",sig.SignDate,sig.ExpireDate)<12Then
MsgBox"Thiscertificatewillexpireinlessthan1year."&vbCrLf&_
"Pleaseuseanewercertificate."
AddSignature=False
sig.Delete
Else
AddSignature=True
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 960
SignerPropertyReturnsaStringrepresentingthenameofthepersonwhoattachedthedigitalcertificatethatcorrespondstotheSignatureobjecttothedocument.Read-only.
expression.Signer
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 961
Example
ThefollowingexamplepromptstheusertoselectadigitalsignaturewithwhichtosigntheactivedocumentinMicrosoftWord.Tousethisexample,openadocumentinWordandpassthisfunctionthenameofacertificateissuerandthenameofacertificatesignerthatmatchtheIssuedByandIssuedTofieldsofadigitalcertificateintheDigitalCertificatesdialogbox.Thisexamplewilltesttomakesurethatthedigitalsignaturethattheuserselectsmeetscertaincriteria,suchasnothavingexpired,beforethenewsignatureiscommittedtothedisk.
FunctionAddSignature(ByValstrIssuerAsString,_
strSignerAsString)AsBoolean
OnErrorGoToError_Handler
DimsigAsSignature
'Displaythedialogboxthatletsthe
'userselectadigitalsignature.
'Iftheuserselectsasignature,then
'itisaddedtotheSignatures
'collection.Iftheuserdoesn't,then
'anerrorisreturned.
Setsig=ActiveDocument.Signatures.Add
'TestseveralpropertiesbeforecommitingtheSignatureobjecttodisk.
Ifsig.Issuer=strIssuerAnd_
sig.Signer=strSignerAnd_
sig.IsCertificateExpired=FalseAnd_
sig.IsCertificateRevoked=FalseAnd_
sig.IsValid=TrueThen
MsgBox"Signed"
AddSignature=True
'Otherwise,removetheSignatureobjectfromtheSignatureSetcollection.
Else
sig.Delete
MsgBox"Notsigned"
AddSignature=False
EndIf
'CommitallsignaturesintheSignatureSetcollectiontothedisk.
ActiveDocument.Signatures.Commit
ExitFunction
Page 962
Error_Handler:
AddSignature=False
MsgBox"Actioncancelled."
EndFunction
Page 963
SolutionIDPropertyReturnsorsetstheID,oftenagloballyuniqueidentifier(GUID),whichidentifiestheXMLexpansionpackattachedtotheactiveMicrosoftOfficeWord2003documentorMicrosoftOfficeExcel2003workbook.Read/writeString.
expression.SolutionID
expressionRequired.AnexpressionthatreturnsaSmartDocumentobject.
Page 964
Remarks
TheSolutionIDpropertyreturnsanemptystringor"None"whennoXMLexpansionpackisattachedtotheactivedocument.
ProvideappropriatevaluesfortheSolutionIDandSolutionUrlpropertiestoattachanavailableXMLexpansionpacktotheactivedocumenttotransformitintoasmartdocumentwithoutusingthePickSolutionmethod.SettheSolutionIDandSolutionUrlpropertiestoemptystringstoremovetheattachedXMLexpansionpack.
Page 965
Example
ThefollowingexampledetermineswhetheranXMLexpansionpackisattachedtotheactiveExcelworkbookbycheckingtheSolutionIDproperty.
DimobjSmartDocAsOffice.SmartDocument
SetobjSmartDoc=ActiveWorkbook.SmartDocument
IfobjSmartDoc.SolutionID="None"OrobjSmartDoc.SolutionID=""Then
MsgBox"NoXMLexpansionpackattached."
Else
MsgBox"SmartdocumentSolutionID:"&_
objSmartDoc.SolutionID
EndIf
SetobjSmartDoc=Nothing
Page 967
SolutionURLPropertyReturnsorsetsanabsoluteURLwhichprovidesthecompletepathtotheXMLexpansionpackfileattachedtotheactiveMicrosoftOfficeWord2003documentorMicrosoftOfficeExcel2003workbook.Read/writeString.
expression.SolutionURL
expressionRequired.AnexpressionthatreturnsaSmartDocumentobject.
Page 968
Remarks
TheSolutionUrlpropertyreturnsanemptystringwhennoXMLexpansionpackisattachedtotheactivedocument.
ProvideappropriatevaluesfortheSolutionIDandSolutionUrlpropertiestoattachanavailableXMLexpansionpacktotheactivedocumentandtransformitintoasmartdocumentwithoutusingthePickSolutionmethod.SettheSolutionIDandSolutionUrlpropertiestoemptystringstoremovetheattachedXMLexpansionpack
Page 969
Example
ThefollowingexampledetermineswhetheranXMLexpansionpackisattachedtotheactiveWorddocument,thendisplaysthesmartdocument'sSolutionURL.
DimobjSmartDocAsOffice.SmartDocument
SetobjSmartDoc=ActiveDocument.SmartDocument
IfobjSmartDoc.SolutionID="None"OrobjSmartDoc.SolutionID=""Then
MsgBox"NoXMLexpansionpackattached."
Else
MsgBox"SmartdocumentSolutionURL:"&_
objSmartDoc.SolutionURL
EndIf
SetobjSmartDoc=Nothing
Page 970
SoundsPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantproducesthesoundsthatcorrespondtoanimations.Read/writeBoolean.
Page 971
Remarks
ThedefaultvalueisTrue.TheSoundspropertycorrespondstotheMakesoundsoptionunderUsetheOfficeAssistantontheOptionstabintheOfficeAssistantdialogbox.Ifasoundcardisnotinstalled,thispropertyhasnoeffect.
Page 972
Example
ThisexampledisplaysandanimatestheOfficeAssistantandallowssound.
WithAssistant
.Visible=True
.On=True
IfNotSoundsThenSounds=True
.Animation=msoAnimationGreeting
EndWith
Page 973
SourceURLPropertyDesignatesthelocationofthepubliccopyofashareddocumenttowhichchangesshouldbepublishedbackafterthedocumenthasbeenrevisedinaseparatedocumentworkspace.Read-onlyString.
expression.SourceURL
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 974
Remarks
TheMicrosoftWindowsSharePointServicesuserinterfaceallowsuserstocopyapublicshareddocumentfromadocumentlibrarytoaseparatedocumentworkspacefortemporarycollaborationpurposes,thenpublishchangesbacktotheoriginalsourcelocation.TheSourceURLpropertyindicatestheoriginalsourcelocationofadocumentcopystoredinatemporaryworkspace.
Page 976
StatePropertyStatepropertyasitappliestotheCommandBarButtonobject.
Returnsorsetstheappearanceofacommandbarbuttoncontrol.Read/writeMsoButtonState.HowevertheStatepropertyofbuilt-incommandbarbuttonsisread-only.
MsoButtonStatecanbeoneoftheseMsoButtonStateconstants.msoButtonDownmsoButtonMixedmsoButtonUp
expression.State
expressionRequired.AnexpressionthatreturnsaCommandBarButtonobject.
StatepropertyasitappliestotheHTMLProjectobject.
ReturnsthecurrentstateofanHTMLProjectobject.Read-onlyMsoHTMLProjectState.
MsoHTMLProjectStatecanbeoneoftheseMsoHTMLProjectStateconstants.msoHTMLProjectStateDocumentLockedmsoHTMLProjectStateDocumentProjectUnlockedmsoHTMLProjectStateProjectLocked
expression.State
expressionRequired.AnexpressionthatreturnsanHTMLProjectobject.
Page 977
Example
AsitappliestotheCommandBarButtonobject.
ThisexamplecreatesacommandbarnamedCustomandaddstwobuttonstoit.TheexamplethensetsthebuttononthelefttomsoButtonUpandsetsthebuttonontherighttomsoButtonDown.
DimmyBarAsOffice.CommandBar
DimimgSourceAsOffice.CommandBarButton
DimmyControl1AsOffice.CommandBarButton
DimmyControl2AsOffice.CommandBarButton
'Addnewcommandbar.
SetmyBar=CommandBars.Add(Name:="Custom",Position:=msoBarTop,Temporary:=True)
'Add2buttonstonewcommandbar.
WithmyBar
.Controls.AddType:=msoControlButton
.Controls.AddType:=msoControlButton
.Visible=True
EndWith
'PasteBoldbuttonfaceandsetStateoffirstbutton.
SetmyControl1=myBar.Controls(1)
SetimgSource=CommandBars.FindControl(msoControlButton,113)
imgSource.CopyFace
WithmyControl1
.PasteFace
.State=msoButtonUp
EndWith
'PasteItalicsbuttonfaceandsetStateofsecondbutton.
SetmyControl2=myBar.Controls(2)
SetimgSource=CommandBars.FindControl(msoControlButton,114)
imgSource.CopyFace
WithmyControl2
.PasteFace
.State=msoButtonDown
EndWith
Page 980
StatusPropertyStatuspropertyasitappliestotheSharedWorkspaceTaskobject.
Returnsorsetsthestatusofthespecifiedsharedworkspacetask.Read/writemsoSharedWorkspaceTaskStatus.
MsoSharedWorkspaceTaskStatuscanbeoneofthesemsoSharedWorkspaceTaskStatusconstants.msoSharedWorkspaceTaskStatusComplete(3)msoSharedWorkspaceTaskStatusDeferred(2)msoSharedWorkspaceTaskStatusInProgress(1)msoSharedWorkspaceTaskStatusNotStarted(4)msoSharedWorkspaceTaskStatusWaiting(5)
expression.Status
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceTaskobject.
Page 981
Remarks
Thesharedworkspacetaskschemaontheservercanbecustomized.CustomizationoftheschemamayaffectthetaskstatusenumerationwhentheAddorSavemethodiscalled.Statuspropertyvaluesaremappedasfollows:
Downloadedvalues1through5aremappedtomsoSharedWorkspaceTaskStatusenumerationvalues1through5.Schemavaluesbeyond5aremappedtoenumerationvalue1(msoSharedWorkspaceTaskStatusInProgress).Uploadedenumerationvalues1through5aremappedtoschemavalues1through5.Ifauser-specifiedvaluedoesnotmaptoanyvaluedefinedintheschema,theuser-specifiedvalueissilentlyignoredandtheStatuspropertyisnotupdatedontheserver.
StatuspropertyasitappliestotheSyncobject.
Returnsthestatusofthesynchronizationofthelocalcopyoftheactivedocumentwiththeservercopy.Read-onlyMsoSyncStatusType.
MsoSyncStatusTypecanbeoneofthefollowingmsoSyncStatusTypeconstants.msoSyncStatusConflict(4)msoSyncStatusError(6)msoSyncStatusLatest(1)msoSyncStatusLocalChanges(3)msoSyncStatusNewerAvailable(2)msoSyncStatusNoSharedWorkspace(0)msoSyncStatusSuspended(5)
expression.Status
expressionRequired.AnexpressionthatreturnsaSyncobject.
Page 982
Remarks
UsetheStatuspropertytodeterminewhetherthelocalcopyoftheactivedocumentissynchronizedwiththesharedservercopy.UsetheGetUpdatemethodtorefreshthestatus.Usethefollowingmethodsandpropertieswhenappropriatetorespondtovariousstatusconditions:
msoSyncStatusConflict-Truewhenboththelocalandtheservercopieshavechanges.UsetheResolveConflictmethodtoresolvethedifferences.msoSyncStatusError-ChecktheErrorTypeproperty.msoSyncStatusLocalChanges-Truewhenonlythelocalcopyhaschanges.UsethePutUpdatemethodtosavelocalchangestotheservercopy.msoSyncStatusNewerAvailable-Truewhenonlytheservercopyhaschanges.Closeandre-openthedocumenttoworkwiththelatestcopyfromtheserver.msoSyncStatusSuspended-UsetheUnsuspendmethodtoresumesynchronization.
TheStatuspropertyreturnsasingleconstantfromthelistinthefollowingorderofprecedence:
1. msoSyncStatusNoSharedWorkspace2. msoSyncStatusError3. msoSyncStatusSuspended4. msoSyncStatusConflict5. msoSyncStatusNewerAvailable6. msoSyncStatusLocalChanges7. msoSyncStatusLatest
Page 983
Example
AsitappliestotheSharedWorkspaceTaskobject.
ThefollowingexampledisplaysalistofalltasksinthecurrentsharedworkspacewhosestatusisnotsettoComplete.
DimswsTaskAsOffice.SharedWorkspaceTask
DimstrTaskStatusAsString
ForEachswsTaskInActiveWorkbook.SharedWorkspace.Tasks
IfswsTask.Status<>msoSharedWorkspaceTaskStatusCompletedThen
strTaskStatus=strTaskStatus&swsTask.Title&vbCrLf
EndIf
Next
MsgBox"Thefollowingtaskshavenotbeencompleted:"&vbCrLf&_
strTaskStatus,vbInformation+vbOKOnly,"IncompleteTasks"
SetswsTask=Nothing
AsitappliestotheSyncobject.
ThefollowingexampleexaminestheStatuspropertyandtakesanappropriateactiontosynchronizethelocalandservercopiesofthedocumentifnecessary.
DimobjSyncAsOffice.Sync
DimstrStatusAsString
SetobjSync=ActiveDocument.Sync
IfobjSync.Status>msoSyncStatusNoSharedWorkspaceThen
SelectCaseobjSync.Status
CasemsoSyncStatusConflict
objSync.ResolveConflictmsoSyncConflictMerge
ActiveDocument.Save
objSync.ResolveConflictmsoSyncConflictClientWins
strStatus="Conflictresolvedbymergingchanges."
CasemsoSyncStatusError
strStatus="Lasterrortype:"&objSync.ErrorType
CasemsoSyncStatusLatest
strStatus="Documentcopiesalreadyinsync."
CasemsoSyncStatusLocalChanges
objSync.PutUpdate
strStatus="Localchangessavedtoserver."
CasemsoSyncStatusNewerAvailable
strStatus="Newercopyavailableontheserver."
CasemsoSyncStatusSuspended
objSync.Unsuspend
Page 984
strStatus="Synchronizationresumed."
EndSelect
Else
strStatus="Notasharedworkspacedocument."
EndIf
MsgBoxstrStatus,vbInformation+vbOKOnly,"SyncInformation"
SetobjSync=Nothing
Page 985
StoreLicensesPropertyReturnsaBooleanvaluethatindicateswhethertheuser'slicensetoviewtheactivedocumentshouldbecachedtoallowofflineviewingwhentheusercannotconnecttoarightsmanagementserver.Read/writeBoolean.DefaultisTrue.
expression.StoreLicenses
expressionRequired.AnexpressionthatreturnsaPermissionobject.
Page 986
Remarks
TheStoreLicensespropertycorrespondsto(anditsvalueistheoppositeof)theRequireaconnectiontoverifyauser'spermissionoptioninthepermissionsuserinterface.WhenStoreLicensesisFalse,usersotherthanthedocumentownermustconnecttotherightsmanagementserverandacquirethelicensetoworkwiththedocumenteachtimetheyopenit.
WhencontentisprotectedusingtheMicrosoftOffice2003InformationRightsManagementservice,theStoreLicensespropertyisalwaysTrueandcannotbesettoFalse.
Page 987
Example
Thefollowingexampledisplaysinformationaboutthepermissionssettingsoftheactivedocument,includingtheStoreLicensessetting.
DimirmPermissionAsOffice.Permission
DimstrIRMInfoAsString
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
strIRMInfo="Permissionsarerestrictedonthisdocument."&vbCrLf
strIRMInfo=strIRMInfo&"Viewintrustedbrowser:"&_
irmPermission.EnableTrustedBrowser&vbCrLf&_
"Documentauthor:"&irmPermission.DocumentAuthor&vbCrLf&_
"Userswithpermissions:"&irmPermission.Count&vbCrLf&_
"Cachelicenseslocally:"&irmPermission.StoreLicenses&vbCrLf&_
"RequestpermissionURL:"&irmPermission.RequestPermissionURL&vbCrLf
IfirmPermission.PermissionFromPolicyThen
strIRMInfo=strIRMInfo&"Permissionsappliedfrompolicy:"&vbCrLf&_
"Policyname:"&irmPermission.PolicyName&vbCrLf&_
"Policydescription:"&irmPermission.PolicyDescription
Else
strIRMInfo=strIRMInfo&"Custompermissionsapplied."
EndIf
Else
strIRMInfo="PermissionsareNOTrestrictedonthisdocument."
EndIf
MsgBoxstrIRMInfo,vbInformation+vbOKOnly,"IRMInformation"
SetirmPermission=Nothing
Page 989
StylePropertyStylepropertyasitappliestotheCommandBarButtonobject.
Returnsorsetsthewayacommandbarbuttoncontrolisdisplayed.Read/writeMsoButtonStyle.
MsoButtonStylecanbeoneoftheseMsoButtonStyleconstants.msoButtonAutomaticmsoButtonCaptionmsoButtonIconmsoButtonIconAndCaptionmsoButtonIconAndCaptionBelowmsoButtonIconAndWrapCaptionmsoButtonIconAndWrapCaptionBelowmsoButtonWrapCaption
StylepropertyasitappliestotheCommandBarComboBoxobject.
Returnsorsetsthewayacommandbarcomboboxcontrolisdisplayed.CanbeeitherofthefollowingMsoComboStyleconstants:msoComboLabelormsoComboNormal.Read/writeMsoComboStyle.
MsoComboStylecanbeoneoftheseMsoComboStyleconstants.msoComboLabelmsoComboNormal
Page 990
Example
Thisexamplecreatesashortcutmenucontainingabuttoncontrolandacomboboxcontrolandsetsthestyleofeach.
SetmyBar=CommandBars_
.Add(Name:="Custom1",Position:=msoBarPopup,Temporary:=False)
WithmyBar
.Controls.AddType:=msoControlButton,Id:=3
.Controls(1).Style=msoButtonCaption
.Controls.AddType:=msoControlComboBox
With.Controls(2)
.Style=msoComboLabel
.AddItem"vanilla"
.AddItem"chocolate"
.AddItem"cookiedough"
EndWith
EndWith
myBar.ShowPopup
Page 991
TablePropertyReturnsaStringthatrepresentsthenameofthetablewithinthedatasourcefilethatcontainsthemailmergerecords.Thereturnedvaluemaybeblankifthetablenameisunknownornotapplicabletothecurrentdatasource.Read-only.
expression.Table
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 992
Example
Thisexamplesetsthenameofthetableifthetablenameiscurrentlyblank.
SubOfficeTest()
DimappOfficeAsOfficeDataSourceObject
SetappOffice=Application.OfficeDataSourceObject
appOffice.OpenbstrConnect:="DRIVER=SQLServer;SERVER=ServerName;"&_
"UID=user;PWD=;DATABASE=Northwind",bstrTable:="Employees"
IfappOffice.Table=""Then
appOffice.Table="Employees"
EndIf
EndSub
Page 994
TagPropertyReturnsorsetsinformationaboutthecommandbarcontrol,suchasdatathatcanbeusedasanargumentinprocedures,orinformationthatidentifiesthecontrol.Read/writeString.
expression.Tag
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 995
Remarks
Toavoidduplicatecallsofthesameclasswhentiggeredwithevents,definetheTagpropertyuniquetotheevents.Thefollowingexampledemonstratesthisconceptwithtwomodules.
PublicWithEventsoBtnAsCommandBarButton
PrivateSuboBtn_click(ByValctrlAsOffice.CommandBarButton,CancelDefaultAsBoolean)
MsgBox"Clicked"&ctrl.Caption
EndSub
DimoBtnsAsNewCollection
SubUse_Tag()
DimoEvtAsCBtnEvent
SetoBtns=Nothing
Fori=1To5
SetoEvt=NewCBtnEvent
SetoEvt.oBtn=Application.CommandBars("WorksheetMenuBar").Controls.Add(msoControlButton)
WithoEvt.oBtn
.Caption="Btn"&i
.Style=msoButtonCaption
.Tag="Hello"&i
EndWith
oBtns.AddoEvt
Next
EndSub
Page 996
Example
Thisexamplesetsthetagforthebuttononthecustomcommandbarto"SpellingButton"anddisplaysthetaginamessagebox.
CommandBars("Custom").Controls(1).Tag="SpellingButton"
MsgBox(CommandBars("Custom").Controls(1).Tag)
Page 997
TasksPropertyReturnsaSharedWorkspaceTaskscollectionthatrepresentsthelistoftasksinthecurrentsharedworkspace.Read-only.
expression.Tasks()
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 998
Example
Thefollowingexampleliststhetasksinthecurrentsharedworkspace.
DimswsTasksAsOffice.SharedWorkspaceTasks
SetswsTasks=ActiveWorkbook.SharedWorkspace.Tasks
MsgBox"Thereare"&swsTasks.Count&_
"task(s)inthecurrentsharedworkspace.",_
vbInformation+vbOKOnly,_
"CollectionInformation"
SetswsTasks=Nothing
Page 1000
TextPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
BalloonLabelorBalloonCheckboxobject:ReturnsorsetsthetextdisplayednexttoacheckboxorlabelintheOfficeAssistantballoon.Read/writeString.
Balloonobject:ReturnsorsetsthetextdisplayedaftertheheadingbutbeforethelabelsorcheckboxesintheOfficeAssistantballoon.Read/writeString.
CommandBarComboBoxobject:Returnsorsetsthetextinthedisplayoreditportionofthecommandbarcomboboxcontrol.Read/writeString.
HTMLProjectItemobject:ReturnsorsetstheHTMLtextintheHTMLeditor.Read/writeString.
expression.Text
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 1001
Remarks
FortheBalloon,BalloonLabel,andBalloonCheckboxobjects,youcanspecifythataparticulargraphicbedisplayedbyusingthefollowingsyntax:{typelocationsizing_factor},wheretypeisbmp(bitmap)orwmf(Windowsmetafile);locationistheresourceIDorthepathandfilename;andsizing_factordenotesthewidthofthe.wmffile(sizing_factorisomittedfor.bmpfiles).
TheBalloonobjectalsosupportsunderlinedtextandtextthathasoneofthe16systempalettecolorsappliedtoit.Todisplayunderlinedtext,usethesyntax{ul}or{ul1};use{ul0}toturnunderliningoff.Tochangethecoloroftext,precedethetextstringwiththecharactersequence{cfnumber},wherenumberisoneofthesystemcolornumberslistedinthefollowingtable.
Systemcolornumber Color0 Black1 Darkred2 Darkgreen3 Darkyellow4 Darkblue5 Darkmagenta6 Darkcyan7 Lightgray248 Mediumgray249 Red250 Green251 Yellow252 Blue253 Magenta254 Cyan255 White
Ifyouspecifyanumberotherthanoneoftheprecedingsystemcolornumbers,thetextintheOfficeAssistantballoonisblack.
Page 1002
Example
Thisexamplecreatesanewcommandbarnamed"Custom"andaddstoitacomboboxthatcontainsfourlistitems.TheexamplethenusestheTextpropertytosetItem3asthedefaultlistitem.
SetmyBar=CommandBars_
.Add(Name:="Custom",Position:=msoBarTop,_
Temporary:=True)
WithmyBar
.Controls.AddType:=msoControlComboBox,ID:=1
.Visible=True
EndWith
SettestComboBox=CommandBars("Custom").Controls(1)
WithtestComboBox
.AddItem"Item1",1
.AddItem"Item2",2
.AddItem"Item3",3
.AddItem"Item4",4
.Text="Item3"
EndWith
ThisexamplecreatesanewOfficeAssistantballoonwithaheading,text,andthreeregionchoices.TheexampleusestheTextpropertytoprovideballoon-relatedinstructionstotheuserandalabelforeachtextbox.
WithAssistant.NewBalloon
.Heading="RegionalSalesData"
.Text="Selectaregion"
Fori=1To3
.CheckBoxes(i).Text="Region"&i
Next
.Show
EndWith
ThisexamplecreatesanewOfficeAssistantballoonthatcontainsunderlinedheadingtext,redtext,andbluetextthatisalsounderlined.
WithAssistant.NewBalloon
.Heading="Underlined{ul1}Heading{ul0}"
.Text="Some{cf249}Red{cf0}textandsome"&_
"underlined{cf252}{ul1}Blue{ul0}{cf0}text."
Page 1003
.Show
EndWith
ThisexamplecreatesanewOfficeAssistantballoonthatcontainsaWindowsmetafile.
WithAssistant.NewBalloon
.Heading="Underlined{ul1}Heading{ul0}"
.Text="{WMF""C:\Favorites\MyPicture.WMF""}"
.Show
EndWith
Page 1004
TextOrPropertyPropertyReturnsorsetsthewordorphrasetobesearchedfor,ineitherthebodyofafileorthefile'sproperties,duringthefilesearch.Thewordorphrasecanincludethe*(asterisk)or?(questionmark)wildcardcharacter.Read/writeString.
Page 1005
Remarks
Usethequestionmarkwildcardcharactertomatchanysinglecharacter.Forexample,typegr?ytofindallfilesthatcontainatleastoneinstanceofeither"gray"or"grey."
Usetheasteriskwildcardcharactertomatchanynumberofcharacters.Forexample,typeSan*toreturnallfilesthatcontainatleastonewordthatbeginswith"San."
Page 1006
Example
ThisexamplesearchestheC:\MyDocumentsfolderandallofitssubfoldersandreturnsallfileswhosebodytextorfilepropertiescontainanywordsthatbeginwith"San."TheTextOrPropertypropertysetsthewordtobesearchedforandlimitsthesearchtoeitherthebodyofthefileorthefileproperties.
WithApplication.FileSearch
.NewSearch
.LookIn="C:\MyDocuments"
.SearchSubFolders=True
.TextOrProperty="San*"
.FileType=msoFileTypeAllFiles
EndWith
Page 1007
TipOfDayPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
TrueiftheOfficeAssistantdisplaysaspecialtipeachtimetheOfficeapplicationisopened.Read/writeBoolean.
Page 1008
Remarks
ThedefaultvalueisFalse.TipOfDaypropertycorrespondstotheShowtheTipoftheDayatstartupoptionunderShowtipsaboutontheOptionstabintheOfficeAssistantdialogbox.
Page 1009
Example
ThisexampledisplaystheOfficeAssistantinaspecificlocationanditsetsseveraloptionsbeforemakingtheAssistantvisible.
WithAssistant
.On=True
.Visible=True
.Left=400
.MoveWhenInTheWay=True
IfNotTipOfDayThenTipOfDay=True
.Animation=msoAnimationGreeting
EndWith
Page 1011
TitlePropertyAsitappliestotheFileDialogobject.
SetsorreturnsthetitleofafiledialogboxdisplayedusingtheFileDialogobject.Read/writeString.
expression.Title
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
AsitappliestotheSharedWorkspaceTaskobject.
SetsorreturnsthetitleofaSharedWorkspaceTaskobject.Read/writeString.
expression.Title
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceTaskobject.
Page 1012
Remarks
TheTitlepropertyisthesinglerequiredpropertyofasharedworkspacetask.UsetheoptionalDescriptionpropertytoprovideorreturnadditionalinformationaboutthetask.
Page 1013
Example
AsitappliestotheFileDialogobject.
ThefollowingexampledisplaysaFilePickerdialogboxusingtheFileDialogobjectanddisplayseachselectedfileinamessagebox.
Submain()
'DeclareavariableasaFileDialogobject.
DimfdAsFileDialog
'CreateaFileDialogobjectasaFilePickerdialogbox.
Setfd=Application.FileDialog(msoFileDialogFilePicker)
'Declareavariabletocontainthepath
'ofeachselecteditem.EventhoughthepathisaString,
'thevariablemustbeaVariantbecauseForEach...Next
'routinesonlyworkwithVariantsandObjects.
DimvrtSelectedItemAsVariant
'UseaWith...EndWithblocktoreferencetheFileDialogobject.
Withfd
'Changethetitleofthedialog
.Title="Archive"
'UsetheShowmethodtodisplaythefilepickerdialogandreturntheuser'saction.
'Iftheuserpressestheactionbutton...
If.Show=-1Then
'StepthrougheachstringintheFileDialogSelectedItemscollection.
ForEachvrtSelectedItemIn.SelectedItems
'vrtSelectedItemisaStringthatcontainsthepathofeachselecteditem.
'YoucanuseanyfileI/Ofunctionsthatyouwanttoworkwiththispath.
'Thisexamplesimplydisplaysthepathinamessagebox.
MsgBox"Selecteditem'spath:"&vrtSelectedItem
NextvrtSelectedItem
'IftheuserpressesCancel...
Else
EndIf
EndWith
'SettheobjectvariabletoNothing.
Page 1014
Setfd=Nothing
EndSub
AsitappliestotheSharedWorkspaceTaskobject.
Thefollowingexampledisplaysalistofthetitlesofalltasksinthecurrentsharedworkspace.
DimswsTaskAsOffice.SharedWorkspaceTask
DimstrTasksAsString
ForEachswsTaskInActiveWorkbook.SharedWorkspace.Tasks
strTasks=strTasks&swsTask.Title&vbCrLf
Next
MsgBoxstrTasks,vbInformation+vbOKOnly,_
"TasksinSharedWorkspace"
SetswsTask=Nothing
Page 1015
TooltipTextPropertyReturnsorsetsthetextdisplayedinacommandbarcontrol'sScreenTip.Read/writeString.
Page 1016
Remarks
Bydefault,thevalueoftheCaptionpropertyisusedastheScreenTip.
Page 1017
Example
ThisexampleaddsaScreenTiptothelastcontrolontheactivemenubar.
SetmyMenuBar=CommandBars.ActiveMenuBar
SetlastCtrl=myMenuBar_
.Controls(myMenuBar.Controls.Count)
lastCtrl.BeginGroup=True
lastCtrl.TooltipText="ClickforhelponUIfeature"
Page 1019
TopPropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
ToppropertyasitappliestotheAssistantandCommandBarobjects.
Setsorreturnsthedistance(inpoints)fromthetopoftheOfficeAssistant,orfromthetopedgeofthespecifiedcommandbar,tothetopedgeofthescreen.Fordockedcommandbars,thispropertyreturnsorsetsthedistancefromthecommandbartothetopofthedockingarea.Read/writeLong.
expression.Top
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
ToppropertyasitappliestotheCommandBarButton,CommandBarComboBox,CommandBarControl,andCommandBarPopupobjects.
Returnsthedistance(inpixels)fromthetopedgeofthespecifiedcommandbarcontroltothetopedgeofthescreen.Read-onlyLong.
expression.Top
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
Page 1020
Example
AsitappliestotheAssistantandCommandBarobjects.
ThisexamplemovestheOfficeAssistanttoanothercoordinateandsetsitsToppropertyforsubsequentappearances.
WithAssistant
.On=True
.Visible=True
.Sounds=True
.Animation=msoAnimationBeginSpeaking
EndWith
Assistant.Top=100
MsgBox"ClickOKtomovetheAssistanttoa"&_
"newlocation."
Assistant.Top=500
Thisexamplepositionstheupper-leftcornerofthefloatingcommandbarnamedCustom140pixelsfromtheleftedgeofthescreenand100pixelsfromthetopofthescreen.
SetmyBar=CommandBars("Custom")
myBar.Position=msoBarFloating
WithmyBar
.Left=140
.Top=100
EndWith
Page 1022
TypePropertyTypepropertyasitappliestotheCommandBarobject.
Returnsthetypeofcommandbar.Read-onlyMsoBarType.
MsoBarTypecanbeoneoftheseMsoBarTypeconstants.msoBarTypeMenuBarmsoBarTypeNormalmsoBarTypePopup
expression.Type
expressionRequired.AnexpressionthatreturnsaCommandBarobject.
TypepropertyasitappliestotheCommandBarButton,CommandBarComboBox,CommandBarControl,andCommandBarPopupobjects.
Returnsthetypeofcommandbarcontrol.Read-onlyMsoControlType.
MsoControlTypecanbeoneoftheseMsoControlTypeconstants.msoControlActiveXmsoControlAutoCompleteCombomsoControlButtonmsoControlButtonDropdownmsoControlButtonPopupmsoControlComboBoxmsoControlCustommsoControlDropdownmsoControlEditmsoControlExpandingGridmsoControlGauge
Page 1023
msoControlGenericDropdownmsoControlGraphicCombomsoControlGraphicDropdownmsoControlGraphicPopupmsoControlGridmsoControlLabelmsoControlLabelExmsoControlOCXDropdownmsoControlPanemsoControlPopupmsoControlSpinnermsoControlSplitButtonMRUPopupmsoControlSplitButtonPopupmsoControlSplitDropdownmsoControlSplitExpandingGridmsoControlWorkPane
expression.Type
expressionRequired.Anexpressionthatreturnsoneoftheaboveobjects.
TypepropertyasitappliestotheSearchScopeobject.
ReturnsavaluethatcorrespondstothetypeofSearchScopeobject.ThetypeindicatestheareainwhichtheExecutemethodoftheFileSearchobjectwillsearchforfiles.Read-onlyMsoSearchIn.
MsoSearchIncanbeoneoftheseMsoSearchInconstants.msoSearchInCustommsoSearchInMyComputermsoSearchInMyNetworkPlacesmsoSearchInOutlook
expression.Type
expressionRequired.AnexpressionthatreturnsaSearchScopeobject.
Page 1024
TypepropertyasitappliestotheDocumentPropertyobject.
Returnsorsetsthedocumentpropertytype.Read-onlyforbuilt-indocumentproperties;read/writeforcustomdocumentproperties.
expression.Type
expressionRequired.AnexpressionthatreturnsaDocumentPropertyobject.
Page 1025
Remarks
ThereturnvaluewillbeaMsoDocPropertiesconstant.
MsoDocPropertiescanbeoneoftheseMsoDocPropertiesconstants.msoPropertyTypeBooleanmsoPropertyTypeDatemsoPropertyTypeFloatmsoPropertyTypeNumbermsoPropertyTypeString
Page 1026
Example
AsitappliestotheCommandBarobject.
ThisexamplefindsthefirstcontrolonthecommandbarnamedCustom.UsingtheTypeproperty,theexampledetermineswhetherthecontrolisabutton.Ifthecontrolisabutton,theexamplecopiesthefaceoftheCopybutton(ontheStandardtoolbar)andthenpastesitontothecontrol.
SetoldCtrl=CommandBars("Custom").Controls(1)
IfoldCtrl.Type=msoControlButtonThen
SetnewCtrl=CommandBars.FindControl(Type:=_
MsoControlButton,ID:=_
CommandBars("Standard").Controls("Copy").ID)
NewCtrl.CopyFace
OldCtrl.PasteFace
EndIf
AsitappliestotheDocumentPropertyobject.
Thisexampledisplaysthename,type,andvalueofadocumentproperty.YoumustpassavalidDocumentPropertyobjecttotheprocedure.
SubDisplayPropertyInfo(dpAsDocumentProperty)
MsgBox"value="&dp.Value&Chr(13)&_
"type="&dp.Type&Chr(13)&_
"name="&dp.Name
EndSub
Page 1028
URLPropertyAsitappliestotheSharedWorkspaceobject.
Returnsthetop-levelUniformResourceLocator(URL)ofthesharedworkspace.Read-onlyString.
expression.URL
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceobject.
Page 1029
Remarks
TheURLpropertyreturnstheaddressofthesharedworkspaceinthisformat:http://server/sites/user/workspace/.
TheURLpropertyreturnsaURL-encodedstring.Forexample,aspaceinthefoldernameisrepresentedby%20.Useasimplefunctionlikethefollowingexampletoreplacethisescapedcharacterwithaspace.
PrivateFunctionURLDecode(URLtoDecodeAsString)AsString
URLDecode=Replace(URLtoDecode,"%20","")
EndFunction
AsitappliestotheSharedWorkspaceFileobject.
ReturnsthefullUniformResourceLocator(URL)andfilenameofthesharedworkspacefile.Read-onlyString.
expression.URL
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceFileobject.
Page 1030
Remarks
TheURLpropertyreturnstheaddressofthesharedworkspacefileinthisformat:http://server/sites/user/workspace/Shared%Documents/MyWorkbook.xls.
TheURLpropertyreturnsaURL-encodedstring.Forexample,aspaceinthefoldernameisrepresentedby%20.
TheSharedWorkspaceFileobjectdoesnothaveaNameorFileNameproperty.ThefilenamemustbeextractedfromtheURLproperty.UsesimplefunctionsasinthefollowingexampletoextractthefilenameandtodecodespacesintheURL.
PrivateFunctionFilenameFromURL(FileURLAsString)AsString
DimintLastSeparatorAsInteger
FileURL=URLDecode(FileURL)
intLastSeparator=InStrRev(FileURL,"/")
FilenameFromURL=Right(FileURL,Len(FileURL)-intLastSeparator)
EndFunction
PrivateFunctionURLDecode(URLtoDecodeAsString)AsString
URLDecode=Replace(URLtoDecode,"%20","")
EndFunction
AsitappliestotheSharedWorkspaceLinkobject.
ReturnsorsetstheUniformResourceLocator(URL)ofthelinksavedinthesharedworkspace.Read/writeString.
expression.URL
expressionRequired.AnexpressionthatreturnsaSharedWorkspaceLinkobject.
Page 1031
Remarks
UsetheURLpropertyoftheSharedWorkspaceLinkobjecttoretrievethewebaddresssavedinthesharedworkspacelink.UsetheoptionalDescriptionandNotespropertiestoretrieveadditionalinformationaboutthelink.
TheURLpropertyreturnsaURL-encodedstring.Forexample,aspaceinthefoldernameisrepresentedby%20.Useasimplefunctionlikethefollowingexampletoreplacethisescapedcharacterwithaspace.
PrivateFunctionURLDecode(URLtoDecodeAsString)AsString
URLDecode=Replace(URLtoDecode,"%20","")
EndFunction
Page 1032
Example
AsitappliestotheSharedWorkspaceobject.
ThefollowingexampledisplaysthebaseURLofthesharedworkspace.
MsgBox"URL:"&ActiveWorkbook.SharedWorkspace.URL,_
vbInformation+vbOKOnly,"SharedWorkspaceURL"
AsitappliestotheSharedWorkspaceFileobject.
ThefollowingexamplelocatesallMicrosoftExcelworkbooksintheSharedWorkspaceFilescollectionbyexaminingtheURLpropertyofeachfileforthe"xls"fileextension.
DimstrExcelFilesAsString
DimswsFileAsOffice.SharedWorkspaceFile
ForEachswsFileInActiveWorkbook.SharedWorkspace.Files
IfRight(swsFile.URL,3)="xls"Then
strExcelFiles=strExcelFiles&swsFile.URL&vbCrLf
EndIf
Next
MsgBox"ExcelFiles:"&vbCrLf&strExcelFiles,_
vbInformation+vbOKOnly,"ExcelFilesinSharedWorkspace"
Thefollowingexamplelistsallfilesinthesharedworkspace,usingsupportingfunctionstoextracttheirfilenamesfromtheURLandtoconvertURL-encodedspacesfrom%20toaspacecharacter.
DimswsFileAsOffice.SharedWorkspaceFile
DimstrFileListAsString
ForEachswsFileInActiveWorkbook.SharedWorkspace.Files
strFileList="Filename:"&FilenameFromURL(swsFile.URL)&_
vbCrLf&"URL:"&URLDecode(swsFile.URL)&vbCrLf
Next
MsgBoxstrFileList,vbInformation+vbOKOnly,"FilesinSharedWorkspace"
SetswsFile=Nothing
PrivateFunctionFilenameFromURL(FileURLAsString)AsString
DimintLastSeparatorAsInteger
FileURL=URLDecode(FileURL)
intLastSeparator=InStrRev(FileURL,"/")
FilenameFromURL=Right(FileURL,Len(FileURL)-intLastSeparator)
Page 1033
EndFunction
PrivateFunctionURLDecode(URLtoDecodeAsString)AsString
URLDecode=Replace(URLtoDecode,"%20","")
EndFunction
AsitappliestotheSharedWorkspaceLinkobject.
ThefollowingexamplelocatesalllinkstotheMicrosoftDeveloperNetwork(MSDN)websiteintheSharedWorkspaceLinkscollectionbyexaminingtheURLpropertyofeachlinkforthestring"msdn".
DimstrMSDNLinksAsString
DimswsLinkAsOffice.SharedWorkspaceLink
ForEachswsLinkInActiveWorkbook.SharedWorkspace.Links
IfInStr(swsLink.URL,"msdn",vbTextCompare)>0Then
strMSDNLinks=strMSDNLinks&swsLink.URL&vbCrLf
EndIf
Next
MsgBox"MSDNLinks:"&vbCrLf&strMSDNLinks,_
vbInformation+vbOKOnly,"MSDNLinksinSharedWorkspace"
Page 1034
UserIdPropertyReturnstheemailnameoftheuserwhosepermissionsontheactivedocumentaredeterminedbythespecifiedUserPermissionobject.Read-onlyString.
expression.UserId
expressionRequired.AnexpressionthatreturnsaUserPermissionobject.
Page 1035
Remarks
TheUserPermissionobjectassociatesasetofpermissionsontheactivedocumentwithasingleuserandanoptionalexpirationdate.TheUserIDpropertyreturnsthenameinemailformoftheuserwhosepermissionsaredeterminedbythespecifiedUserPermissionobject.
Page 1036
Example
Thefollowingexampleliststheuserswhohavepermissionsontheactivedocument.
DimirmPermissionAsOffice.Permission
DimirmUserPermAsOffice.UserPermission
DimstrUsersAsString
SetirmPermission=ActiveWorkbook.Permission
IfirmPermission.EnabledThen
ForEachirmUserPermInirmPermission
strUsers=strUsers&irmUserPerm.UserId&vbCrLf
Next
MsgBoxstrUsers,_
vbInformation+vbOKOnly,"IRMInformation"
Else
MsgBox"Permissionsarenotenabledforthisdocument.",_
vbInformation+vbOKOnly,"IRMInformation"
EndIf
SetirmUserPerm=Nothing
SetirmPermission=Nothing
Page 1038
ValuePropertyValuepropertyasitappliestotheDocumentPropertyobject.
Returnsorsetsthevalueofadocumentproperty.Read/writeVariant.
expression.Value
expressionRequired.AnexpressionthatreturnsaDocumentPropertyobject.
Page 1039
Remarks
Ifthecontainerapplicationdoesn'tdefineavalueforoneofthebuilt-indocumentproperties,readingtheValuepropertyforthatdocumentpropertycausesanerror.
ValuepropertyasitappliestothePropertyTestobject.
Returnsthevalueofapropertytestforafilesearch.Read-onlyVariant.
expression.Value
expressionRequired.AnexpressionthatreturnsaPropertyTestobject.
Page 1040
Example
AsitappliestotheDocumentPropertyobject.
Thisexampledisplaysthename,type,andvalueofadocumentproperty.Fortheexampletowork,dpmustbeavalidDocumentPropertyobject.
SubDisplayPropertyInfo(dpAsDocumentProperty)
MsgBox"value="&dp.Value&Chr(13)&_
"type="&dp.Type&Chr(13)&_
"name="&dp.Name
EndSub
AsitappliestothePropertyTestobject.
Thisexampledisplaysthevalueofthesearchcriteria(ifitexists)inamessagebox.Ifthesecondvaluedoesn'texist,theexampledisplaysanothermessage.
WithApplication.FileSearch.PropertyTests(1)
If.Value=""Then
MsgBox"Youhaven'tspecifiedavalue."
Else
MsgBox"Thevalueyou'vesetis:"_
&.Value
EndIf
EndWith
Page 1041
VisiblePropertySomeofthecontentinthistopicmaynotbeapplicabletosomelanguages.
Trueifthespecifiedobjectisvisible.Read/writeBoolean.
expression.Visible
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 1042
Remarks
TheVisiblepropertyfornewlycreatedcustomcommandbarsisFalsebydefault.
TheEnabledpropertyforacommandbarmustbesettoTruebeforethevisiblepropertyissettoTrue.
Page 1043
Example
ThisexamplestepsthroughthecollectionofcommandbarstofindtheFormscommandbar.IftheFormscommandbarisfound,theexamplemakesitvisibleandprotectsitsdockingstate.
foundFlag=False
ForEachcmdbarInCommandBars
Ifcmdbar.Name="Forms"Then
cmdbar.Protection=msoBarNoChangeDock
cmdbar.Visible=True
foundFlag=True
EndIf
Next
IfNotfoundFlagThen
MsgBox"'Forms'commandbarisnotinthecollection."
EndIf
ThisexamplemakestheOfficeAssistantvisibleandsetsitsanimation.
WithApplication.Assistant
.Visible=True
.Sounds=True
.Animation=msoAnimationBeginSpeaking
EndWith
Page 1045
WidthPropertyReturnsorsetsthewidth(inpixels)ofthespecifiedcommandbarorcommandbarcontrol.Read/writeInteger.
expression.Width
expressionRequired.AnexpressionthatreturnsoneoftheobjectsintheAppliesTolist.
Page 1046
Example
ThisexampleaddsacustomcontroltothecommandbarnamedCustom.Theexamplesetstheheightofthecustomcontroltotwicetheheightofthecommandbarandsetsitswidthto50pixels.Noticehowthecommandbarautomaticallyresizesitselftoaccommodatethecontrol.
SetmyBar=CommandBars("Custom")
barHeight=myBar.Height
SetmyControl=myBar.Controls_
.Add(Type:=msoControlButton,_
Id:=CommandBars("Standard").Controls("Save").Id,_
Temporary:=True)
WithmyControl
.Height=barHeight*2
.Width=50
EndWith
myBar.Visible=True
Page 1047
WorkspaceLastChangedByPropertyDisplaysthefriendlynameoftheuserwholastsavedchangestotheservercopyofashareddocument.Read-onlyString.
expression.WorkspaceLastChangedBy
expressionRequired.AnexpressionthatreturnsaSyncobject.
Page 1048
Remarks
Iftheactivedocumentisnotconfiguredforsynchronizationbetweenthelocalcopyandtheservercopy,theWorkspaceLastChangedBypropertyraisesarun-timeerror.
Page 1049
Example
Thefollowingexamplechecksforaconflictbetweenthelocalandtheservercopiesoftheshareddocumentandreportsthenameoftheuserwholastsavedchangestotheservercopy.
DimobjSyncAsOffice.Sync
DimstrStatusAsString
SetobjSync=ActiveDocument.Sync
IfobjSync.Status=msoSyncStatusConflictThen
strStatus="Theservercopyhasbeenchanged."&vbCrLf&_
"Changeshavebeenmadeby:"&_
objSync.WorkspaceLastChangedBy
MsgBoxstrStatus,vbInformation+vbOKOnly,"ServerCopyChanged"
EndIf
SetobjSync=Nothing
Page 1050
ChangeEventOccurswhentheenduserchangestheselectioninacommandbarcombobox.
PrivateSubCommandBarComboBox_Change
(ByValCtrlAsCommandBarComboBox)
Page 1051
Remarks
TheChangeeventisrecognizedbytheCommandBarComboBoxobject.ToreturntheChangeeventforaparticularCommandBarComboBoxcontrol,usetheWithEventskeywordtodeclareavariable,andthensetthevariabletotheCommandBarComboBoxcontrol.WhentheChangeeventistriggered,itexecutesthemacroorcodethatyouspecifiedwiththeOnActionpropertyofthecontrol.
Page 1052
Example
ThefollowingexamplecreatesacommandbarwithaCommandBarComboBoxcontrolcontainingfourselections.ThecomboboxrespondstouserinteractionthroughtheCommandBarComboBox_Changeevent.
PrivatectlComboBoxHandlerAsNewComboBoxHandler
SubAddComboBox()
SetHostApp=Application
DimnewBarAsOffice.CommandBar
SetnewBar=HostApp.CommandBars.Add(Name:="TestCommandBar",Temporary:=True)
DimnewComboAsOffice.CommandBarComboBox
SetnewCombo=newBar.Controls.Add(msoControlComboBox)
WithnewCombo
.AddItem"FirstClass",1
.AddItem"BusinessClass",2
.AddItem"CoachClass",3
.AddItem"Standby",4
.DropDownLines=5
.DropDownWidth=75
.ListHeaderCount=0
EndWith
ctlComboBoxHandler.SyncBoxnewCombo
newBar.Visible=True
EndSub
Theprecedingexamplereliesonthefollowingcode,whichisstoredinaclassmoduleintheVBAproject.
PrivateWithEventsComboBoxEventAsOffice.CommandBarComboBox
PublicSubSyncBox(boxAsOffice.CommandBarComboBox)
SetComboBoxEvent=box
IfNotboxIsNothingThen
MsgBox"Synced"&box.Caption&"ComboBoxevents."
EndIf
EndSub
PrivateSubClass_Terminate()
Page 1053
SetComboBoxEvent=Nothing
EndSub
PrivateSubComboBoxEvent_Change(ByValCtrlAsOffice.CommandBarComboBox)
DimstComboTextAsString
stComboText=Ctrl.Text
SelectCasestComboText
Case"FirstClass"
FirstClass
Case"BusinessClass"
BusinessClass
Case"CoachClass"
CoachClass
Case"Standby"
Standby
EndSelect
EndSub
PrivateSubFirstClass()
MsgBox"YouselectedFirstClassreservations"
EndSub
PrivateSubBusinessClass()
MsgBox"YouselectedBusinessClassreservations"
EndSub
PrivateSubCoachClass()
MsgBox"YouselectedCoachClassreservations"
EndSub
PrivateSubStandby()
MsgBox"Youchosetoflystandby"
EndSub
Page 1054
ClickEventOccurswhentheuserclicksaCommandBarButtonobject.
PrivateSubCommandBarButton_Click
(ByValCtrlAsCommandBarButton,
ByValCancelDefaultAsBoolean)
ThesyntaxfortheClickeventincludesthetwoargumentsdescribedinthefollowingtable.
Argument Description
Ctrl RequiredCommandBarButton.DenotestheCommandBarButtoncontrolthatinitiatedtheevent.
CancelDefaultRequiredBoolean.FalseifthedefaultbehaviorassociatedwiththeCommandBarButtoncontroloccurs,unlessit’scanceledbyanotherprocessoradd-in.
Page 1055
Remarks
TheClickeventisrecognizedbytheCommandBarButtonobject.ToreturntheClickeventforaparticularCommandBarButtoncontrol,usetheWithEventskeywordtodeclareavariable,andthensetthevariabletothecontrol.
Page 1056
Example
ThefollowingexamplecreatesanewcommandbarbuttonontheFilemenuofthehostapplicationthatenablestheusertosaveaworkbookasacomma-separatedvaluefile.(Thisexampleworksinallapplications,butthecontextofsavingasCSVisapplicabletoMicrosoftExcel.)
PrivateHostAppAsObject
SubcreateAndSynch()
DimiIndexAsInteger
DimiCountAsInteger
DimfBtnExistsAsBoolean
DimobCmdBtnAsObject
DimbtnSaveAsCSVHandlerasnewClass1
OnErrorGoToerrHandler
SetHostApp=Application
DimbarHelpAsOffice.CommandBar
SetbarHelp=Application.CommandBars("File")
fBtnExists=False
iCount=barHelp.Controls.Count
ForiIndex=1ToiCount
IfbarHelp.Controls(iIndex).Caption="SaveAsCSV(CommaDelimited)"ThenfBtnExists=True
Next
DimbtnSaveAsCSVAsOffice.CommandBarButton
IffBtnExistsThen
SetbtnSaveAsCSV=barHelp.Controls("SaveAsCSV(CommaDelimited)")
Else
SetbtnSaveAsCSV=barHelp.Controls.Add(msoControlButton)
btnSaveAsCSV.Caption="SaveAsCSV(CommaDelimited)"
EndIf
btnSaveAsCSV.Tag="btn1"
btnSaveAsCSVHandler.SyncButtonbtnSaveAsCSV
ExitSub
errHandler:
'Inserterrorhandlingcodehere
EndSub
Page 1058
EnvelopeHideEventOccurswhentheuserinterface(UI)thatcorrespondstotheMsoEnvelopeobjectishidden.
PrivateSubobject_EnvelopHide()
objectAvariablewhichreferencesanobjectoftypeMsoEnvelopedeclaredwitheventsinaclassmodule.
Page 1059
Example
Thefollowingexamplesetsupevent-handlingroutinesfortheMsoEnvelopeobject.
PublicWithEventsenvAsMsoEnvelope
PrivateSubClass_Initialize()
Setenv=Application.ActiveDocument.MailEnvelope
EndSub
PrivateSubenv_EnvelopeShow()
MsgBox"TheMsoEnvelopeUIisshowing."
EndSub
PrivateSubenv_EnvelopeHide()
MsgBox"TheMsoEnvelopeUIishidden."
EndSub
Page 1060
EnvelopeShowEventOccurswhentheuserinterface(UI)thatcorrespondstotheMsoEnvelopeobjectisdisplayed.
PrivateSubobject_EnvelopShow()
objectAvariablewhichreferencesanobjectoftypeMsoEnvelopedeclaredwitheventsinaclassmodule.
Page 1061
Example
Thefollowingexamplesetsupevent-handlingroutinesfortheMsoEnvelopeobject.
PublicWithEventsenvAsMsoEnvelope
PrivateSubClass_Initialize()
Setenv=Application.ActiveDocument.MailEnvelope
EndSub
PrivateSubenv_EnvelopeShow()
MsgBox"TheMsoEnvelopeUIisshowing."
EndSub
PrivateSubenv_EnvelopeHide()
MsgBox"TheMsoEnvelopeUIishidden."
EndSub
Page 1062
OnUpdateEventOccurswhenanychangeismadetoacommandbar.
PrivateSubCommandBars_OnUpdate()
Page 1063
Remarks
TheOnUpdateeventisrecognizedbytheCommandBarobjectandallcommandbarcontrols.Theeventistriggeredbyanychangetoacommandbarorcommandbarcontroloranychangetothestateofacommandbarorcommandbarcontrol.Thesechangescanoccurduetoatextorcellselection,forexample.SincealargenumberofOnUpdateeventscanoccurduringnormalusage,developersshouldexercisecautionwhenusingthisevent.ItisstronglyrecommendedthatthiseventbeusedprimarilyforcheckingthatacustomcommandbarhasbeenaddedorremovedbyaCOMAddIn.
Page 1065
MicrosoftOfficeEnumeratedConstantsThistopicprovidesalistofallenumeratedconstantsintheMicrosoftOfficeobjectmodel.
MailFormat
Constant ValuemfHTML 2mfPlainText 1mfRTF 3
MsoAlertButtonType
Constant ValuemsoAlertButtonAbortRetryIgnore 2msoAlertButtonOK 0msoAlertButtonOKCancel 1msoAlertButtonRetryCancel 5msoAlertButtonYesAllNoCancel 6msoAlertButtonYesNo 4msoAlertButtonYesNoCancel 3
MsoAlertCancelType
Constant ValuemsoAlertCancelDefault -1msoAlertCancelFifth 4msoAlertCancelFirst 0msoAlertCancelFourth 3msoAlertCancelSecond 1
Page 1066
msoAlertCancelThird 2
MsoAlertDefaultType
Constant ValuemsoAlertDefaultFifth 4msoAlertDefaultFirst 0msoAlertDefaultFourth 3msoAlertDefaultSecond 1msoAlertDefaultThird 2
MsoAlertIconType
Constant ValuemsoAlertIconCritical 1msoAlertIconInfo 4msoAlertIconNoIcon 0msoAlertIconQuery 2msoAlertIconWarning 3
MsoAlignCmd
Constant ValuemsoAlignBottoms 5msoAlignCenters 1msoAlignLefts 0msoAlignMiddles 4msoAlignRights 2msoAlignTops 3
MsoAnimationType
Constant ValuemsoAnimationAppear 32
Page 1067
msoAnimationBeginSpeaking 4msoAnimationCharacterSuccessMajor 6msoAnimationCheckingSomething 103msoAnimationDisappear 31msoAnimationEmptyTrash 116msoAnimationGestureDown 113msoAnimationGestureLeft 114msoAnimationGestureRight 19msoAnimationGestureUp 115msoAnimationGetArtsy 100msoAnimationGetAttentionMajor 11msoAnimationGetAttentionMinor 12msoAnimationGetTechy 101msoAnimationGetWizardy 102msoAnimationGoodbye 3msoAnimationGreeting 2msoAnimationIdle 1msoAnimationListensToComputer 26msoAnimationLookDown 104msoAnimationLookDownLeft 105msoAnimationLookDownRight 106msoAnimationLookLeft 107msoAnimationLookRight 108msoAnimationLookUp 109msoAnimationLookUpLeft 110msoAnimationLookUpRight 111msoAnimationPrinting 18msoAnimationRestPose 5msoAnimationSaving 112msoAnimationSearching 13msoAnimationSendingMail 25msoAnimationThinking 24msoAnimationWorkingAtSomething 23
Page 1068
msoAnimationWritingNotingSomething 22
MsoAppLanguageID
Constant ValuemsoLanguageIDExeMode 4msoLanguageIDHelp 3msoLanguageIDInstall 1msoLanguageIDUI 2msoLanguageIDUIPrevious 5
MsoArrowheadLength
Constant ValuemsoArrowheadLengthMedium 2msoArrowheadLengthMixed -2msoArrowheadLong 3msoArrowheadShort 1
MsoArrowheadStyle
Constant ValuemsoArrowheadDiamond 5msoArrowheadNone 1msoArrowheadOpen 3msoArrowheadOval 6msoArrowheadStealth 4msoArrowheadStyleMixed -2msoArrowheadTriangle 2
MsoArrowheadWidth
Constant ValuemsoArrowheadNarrow 1
Page 1069
msoArrowheadWide 3msoArrowheadWidthMedium 2msoArrowheadWidthMixed -2
MsoAutomationSecurity
Constant ValuemsoAutomationSecurityByUI 2msoAutomationSecurityForceDisable 3msoAutomationSecurityLow 1
MsoAutoShapeType
Constant ValuemsoShape16pointStar 94msoShape24pointStar 95msoShape32pointStar 96msoShape4pointStar 91msoShape5pointStar 92msoShape8pointStar 93msoShapeActionButtonBackorPrevious 129msoShapeActionButtonBeginning 131msoShapeActionButtonCustom 125msoShapeActionButtonDocument 134msoShapeActionButtonEnd 132msoShapeActionButtonForwardorNext 130msoShapeActionButtonHelp 127msoShapeActionButtonHome 126msoShapeActionButtonInformation 128msoShapeActionButtonMovie 136msoShapeActionButtonReturn 133msoShapeActionButtonSound 135msoShapeArc 25msoShapeBalloon 137
Page 1070
msoShapeBentArrow 41msoShapeBentUpArrow 44msoShapeBevel 15msoShapeBlockArc 20msoShapeCan 13msoShapeChevron 52msoShapeCircularArrow 60msoShapeCloudCallout 108msoShapeCross 11msoShapeCube 14msoShapeCurvedDownArrow 48msoShapeCurvedDownRibbon 100msoShapeCurvedLeftArrow 46msoShapeCurvedRightArrow 45msoShapeCurvedUpArrow 47msoShapeCurvedUpRibbon 99msoShapeDiamond 4msoShapeDonut 18msoShapeDoubleBrace 27msoShapeDoubleBracket 26msoShapeDoubleWave 104msoShapeDownArrow 36msoShapeDownArrowCallout 56msoShapeDownRibbon 98msoShapeExplosion1 89msoShapeExplosion2 90msoShapeFlowchartAlternateProcess 62msoShapeFlowchartCard 75msoShapeFlowchartCollate 79msoShapeFlowchartConnector 73msoShapeFlowchartData 64msoShapeFlowchartDecision 63msoShapeFlowchartDelay 84
Page 1071
msoShapeFlowchartDirectAccessStorage 87msoShapeFlowchartDisplay 88msoShapeFlowchartDocument 67msoShapeFlowchartExtract 81msoShapeFlowchartInternalStorage 66msoShapeFlowchartMagneticDisk 86msoShapeFlowchartManualInput 71msoShapeFlowchartManualOperation 72msoShapeFlowchartMerge 82msoShapeFlowchartMultidocument 68msoShapeFlowchartOffpageConnector 74msoShapeFlowchartOr 78msoShapeFlowchartPredefinedProcess 65msoShapeFlowchartPreparation 70msoShapeFlowchartProcess 61msoShapeFlowchartPunchedTape 76msoShapeFlowchartSequentialAccessStorage 85msoShapeFlowchartSort 80msoShapeFlowchartStoredData 83msoShapeFlowchartSummingJunction 77msoShapeFlowchartTerminator 69msoShapeFoldedCorner 16msoShapeHeart 21msoShapeHexagon 10msoShapeHorizontalScroll 102msoShapeIsoscelesTriangle 7msoShapeLeftArrow 34msoShapeLeftArrowCallout 54msoShapeLeftBrace 31msoShapeLeftBracket 29msoShapeLeftRightArrow 37msoShapeLeftRightArrowCallout 57msoShapeLeftRightUpArrow 40
Page 1072
msoShapeLeftUpArrow 43msoShapeLightningBolt 22msoShapeLineCallout1 109msoShapeLineCallout1AccentBar 113msoShapeLineCallout1BorderandAccentBar 121msoShapeLineCallout1NoBorder 117msoShapeLineCallout2 110msoShapeLineCallout2AccentBar 114msoShapeLineCallout2BorderandAccentBar 122msoShapeLineCallout2NoBorder 118msoShapeLineCallout3 111msoShapeLineCallout3AccentBar 115msoShapeLineCallout3BorderandAccentBar 123msoShapeLineCallout3NoBorder 119msoShapeLineCallout4 112msoShapeLineCallout4AccentBar 116msoShapeLineCallout4BorderandAccentBar 124msoShapeLineCallout4NoBorder 120msoShapeMixed -2msoShapeMoon 24msoShapeNoSymbol 19msoShapeNotchedRightArrow 50msoShapeNotPrimitive 138msoShapeOctagon 6msoShapeOval 9msoShapeOvalCallout 107msoShapeParallelogram 2msoShapePentagon 51msoShapePlaque 28msoShapeQuadArrow 39msoShapeQuadArrowCallout 59msoShapeRectangle 1msoShapeRectangularCallout 105
Page 1073
msoShapeRegularPentagon 12msoShapeRightArrow 33msoShapeRightArrowCallout 53msoShapeRightBrace 32msoShapeRightBracket 30msoShapeRightTriangle 8msoShapeRoundedRectangle 5msoShapeRoundedRectangularCallout 106msoShapeSmileyFace 17msoShapeStripedRightArrow 49msoShapeSun 23msoShapeTrapezoid 3msoShapeUpArrow 35msoShapeUpArrowCallout 55msoShapeUpDownArrow 38msoShapeUpDownArrowCallout 58msoShapeUpRibbon 97msoShapeUTurnArrow 42msoShapeVerticalScroll 101msoShapeWave 103
MsoBalloonButtonType
Constant ValuemsoBalloonButtonAbort -8msoBalloonButtonBack -5msoBalloonButtonCancel -2msoBalloonButtonClose -12msoBalloonButtonIgnore -9msoBalloonButtonNext -6msoBalloonButtonNo -4msoBalloonButtonNull 0msoBalloonButtonOK -1
Page 1074
msoBalloonButtonOptions -14msoBalloonButtonRetry -7msoBalloonButtonSearch -10msoBalloonButtonSnooze -11msoBalloonButtonTips -13msoBalloonButtonYes -3msoBalloonButtonYesToAll -15
MsoBalloonErrorType
Constant ValuemsoBalloonErrorBadCharacter 8msoBalloonErrorBadPictureRef 4msoBalloonErrorBadReference 5msoBalloonErrorButtonlessModal 6msoBalloonErrorButtonModeless 7msoBalloonErrorCharNotTopmostForModal 10msoBalloonErrorCOMFailure 9msoBalloonErrorNone 0msoBalloonErrorOther 1msoBalloonErrorOutOfMemory 3msoBalloonErrorTooBig 2msoBalloonErrorTooManyControls 11
MsoBalloonType
Constant ValuemsoBalloonTypeBullets 1msoBalloonTypeButtons 0msoBalloonTypeNumbers 2
MsoBarPosition
Constant Value
Page 1075
msoBarBottom 3msoBarFloating 4msoBarLeft 0msoBarMenuBar 6msoBarPopup 5msoBarRight 2msoBarTop 1
MsoBarProtection
Constant ValuemsoBarNoChangeDock 16msoBarNoChangeVisible 8msoBarNoCustomize 1msoBarNoHorizontalDock 64msoBarNoMove 4msoBarNoProtection 0msoBarNoResize 2msoBarNoVerticalDock 32
MsoBarRow
Constant ValuemsoBarRowFirst 0msoBarRowLast -1
MsoBarType
Constant ValuemsoBarTypeMenuBar 1msoBarTypeNormal 0msoBarTypePopup 2
MsoBlackWhiteMode
Page 1076
Constant ValuemsoBlackWhiteAutomatic 1msoBlackWhiteBlack 8msoBlackWhiteBlackTextAndLine 6msoBlackWhiteDontShow 10msoBlackWhiteGrayOutline 5msoBlackWhiteGrayScale 2msoBlackWhiteHighContrast 7msoBlackWhiteInverseGrayScale 4msoBlackWhiteLightGrayScale 3msoBlackWhiteMixed -2msoBlackWhiteWhite 9
MsoButtonSetType
Constant ValuemsoButtonSetAbortRetryIgnore 10msoButtonSetBackClose 6msoButtonSetBackNextClose 8msoButtonSetBackNextSnooze 12msoButtonSetCancel 2msoButtonSetNextClose 7msoButtonSetNone 0msoButtonSetOK 1msoButtonSetOkCancel 3msoButtonSetRetryCancel 9msoButtonSetSearchClose 11msoButtonSetTipsOptionsClose 13msoButtonSetYesAllNoCancel 14msoButtonSetYesNo 4msoButtonSetYesNoCancel 5
MsoButtonState
Page 1077
Constant ValuemsoButtonDown -1msoButtonMixed 2msoButtonUp 0
MsoButtonStyle
Constant ValuemsoButtonAutomatic 0msoButtonCaption 2msoButtonIcon 1msoButtonIconAndCaption 3msoButtonIconAndCaptionBelow 11msoButtonIconAndWrapCaption 7msoButtonIconAndWrapCaptionBelow 15msoButtonWrapCaption 14
MsoCalloutAngleType
Constant ValuemsoCalloutAngle30 2msoCalloutAngle45 3msoCalloutAngle60 4msoCalloutAngle90 5msoCalloutAngleAutomatic 1msoCalloutAngleMixed -2
MsoCalloutDropType
Constant ValuemsoCalloutDropBottom 4msoCalloutDropCenter 3msoCalloutDropCustom 1msoCalloutDropMixed -2
Page 1078
msoCalloutDropTop 2
MsoCalloutType
Constant ValuemsoCalloutFour 4msoCalloutMixed -2msoCalloutOne 1msoCalloutThree 3msoCalloutTwo 2
MsoCharacterSet
Constant ValuemsoCharacterSetArabic 1msoCharacterSetCyrillic 2msoCharacterSetEnglishWesternEuropeanOtherLatinScript 3msoCharacterSetGreek 4msoCharacterSetHebrew 5msoCharacterSetJapanese 6msoCharacterSetKorean 7msoCharacterSetMultilingualUnicode 8msoCharacterSetSimplifiedChinese 9msoCharacterSetThai 10msoCharacterSetTraditionalChinese 11msoCharacterSetVietnamese 12
MsoColorType
Constant ValuemsoColorTypeCMS 4msoColorTypeCMYK 3msoColorTypeInk 5msoColorTypeMixed -2
Page 1079
msoColorTypeRGB 1msoColorTypeScheme 2
MsoComboStyle
Constant ValuemsoComboLabel 1msoComboNormal 0
MsoCommandBarButtonHyperlinkType
Constant ValuemsoCommandBarButtonHyperlinkInsertPicture 2msoCommandBarButtonHyperlinkNone 0msoCommandBarButtonHyperlinkOpen 1
MsoCondition
Constant ValuemsoConditionAnyNumberBetween 34msoConditionAnytime 25msoConditionAnytimeBetween 26msoConditionAtLeast 36msoConditionAtMost 35msoConditionBeginsWith 11msoConditionDoesNotEqual 33msoConditionEndsWith 12msoConditionEquals 32msoConditionEqualsCompleted 66msoConditionEqualsDeferred 68msoConditionEqualsHigh 60msoConditionEqualsInProgress 65msoConditionEqualsLow 58msoConditionEqualsNormal 59
Page 1080
msoConditionEqualsNotStarted 64msoConditionEqualsWaitingForSomeoneElse 67msoConditionFileTypeAllFiles 1msoConditionFileTypeBinders 6msoConditionFileTypeCalendarItem 45msoConditionFileTypeContactItem 46msoConditionFileTypeDatabases 7msoConditionFileTypeDataConnectionFiles 51msoConditionFileTypeDesignerFiles 56msoConditionFileTypeDocumentImagingFiles 54msoConditionFileTypeExcelWorkbooks 4msoConditionFileTypeJournalItem 48msoConditionFileTypeMailItem 44msoConditionFileTypeNoteItem 47msoConditionFileTypeOfficeFiles 2msoConditionFileTypeOutlookItems 43msoConditionFileTypePhotoDrawFiles 50msoConditionFileTypePowerPointPresentations 5msoConditionFileTypeProjectFiles 53msoConditionFileTypePublisherFiles 52msoConditionFileTypeTaskItem 49msoConditionFileTypeTemplates 8msoConditionFileTypeVisioFiles 55msoConditionFileTypeWebPages 57msoConditionFileTypeWordDocuments 3msoConditionFreeText 42msoConditionIncludes 9msoConditionIncludesFormsOf 41msoConditionIncludesNearEachOther 13msoConditionIncludesPhrase 10msoConditionInTheLast 31msoConditionInTheNext 30msoConditionIsExactly 14
Page 1081
msoConditionIsNo 40msoConditionIsNot 15msoConditionIsYes 39msoConditionLastMonth 22msoConditionLastWeek 19msoConditionLessThan 38msoConditionMoreThan 37msoConditionNextMonth 24msoConditionNextWeek 21msoConditionNotEqualToCompleted 71msoConditionNotEqualToDeferred 73msoConditionNotEqualToHigh 63msoConditionNotEqualToInProgress 70msoConditionNotEqualToLow 61msoConditionNotEqualToNormal 62msoConditionNotEqualToNotStarted 69msoConditionNotEqualToWaitingForSomeoneElse 72msoConditionOn 27msoConditionOnOrAfter 28msoConditionOnOrBefore 29msoConditionThisMonth 23msoConditionThisWeek 20msoConditionToday 17msoConditionTomorrow 18msoConditionYesterday 16
MsoConnector
Constant ValuemsoConnectorAnd 1msoConnectorOr 2
MsoConnectorType
Page 1082
Constant ValuemsoConnectorCurve 3msoConnectorElbow 2msoConnectorStraight 1msoConnectorTypeMixed -2
MsoControlOLEUsage
Constant ValuemsoControlOLEUsageBoth 3msoControlOLEUsageClient 2msoControlOLEUsageNeither 0msoControlOLEUsageServer 1
MsoControlType
Constant ValuemsoControlActiveX 22msoControlAutoCompleteCombo 26msoControlButton 1msoControlButtonDropdown 5msoControlButtonPopup 12msoControlComboBox 4msoControlCustom 0msoControlDropdown 3msoControlEdit 2msoControlExpandingGrid 16msoControlGauge 19msoControlGenericDropdown 8msoControlGraphicCombo 20msoControlGraphicDropdown 9msoControlGraphicPopup 11msoControlGrid 18msoControlLabel 15
Page 1083
msoControlLabelEx 24msoControlOCXDropdown 7msoControlPane 21msoControlPopup 10msoControlSpinner 23msoControlSplitButtonMRUPopup 14msoControlSplitButtonPopup 13msoControlSplitDropdown 6msoControlSplitExpandingGrid 17msoControlWorkPane 25
MsoDiagramNodeType
Constant ValuemsoDiagramAssistant 2msoDiagramNode 1
MsoDiagramType
Constant ValuemsoDiagramCycle 2msoDiagramMixed -2msoDiagramOrgChart 1msoDiagramPyramid 4msoDiagramRadial 3msoDiagramTarget 6msoDiagramVenn 5
MsoDistributeCmd
Constant ValuemsoDistributeHorizontally 0msoDistributeVertically 1
Page 1084
MsoDocProperties
Constant ValuemsoPropertyTypeBoolean 2msoPropertyTypeDate 3msoPropertyTypeFloat 5msoPropertyTypeNumber 1msoPropertyTypeString 4
MsoEditingType
Constant ValuemsoEditingAuto 0msoEditingCorner 1msoEditingSmooth 2msoEditingSymmetric 3
MsoEncoding
Constant ValuemsoEncodingArabic 1256msoEncodingArabicASMO 708msoEncodingArabicAutoDetect 51256msoEncodingArabicTransparentASMO 720msoEncodingAutoDetect 50001msoEncodingBaltic 1257msoEncodingCentralEuropean 1250msoEncodingCyrillic 1251msoEncodingCyrillicAutoDetect 51251msoEncodingEBCDICArabic 20420msoEncodingEBCDICDenmarkNorway 20277msoEncodingEBCDICFinlandSweden 20278msoEncodingEBCDICFrance 20297msoEncodingEBCDICGermany 20273
Page 1085
msoEncodingEBCDICGreek 20423msoEncodingEBCDICGreekModern 875msoEncodingEBCDICHebrew 20424msoEncodingEBCDICIcelandic 20871msoEncodingEBCDICInternational 500msoEncodingEBCDICItaly 20280msoEncodingEBCDICJapaneseKatakanaExtended 20290msoEncodingEBCDICJapaneseKatakanaExtendedAndJapanese 50930msoEncodingEBCDICJapaneseLatinExtendedAndJapanese 50939msoEncodingEBCDICKoreanExtended 20833msoEncodingEBCDICKoreanExtendedAndKorean 50933msoEncodingEBCDICLatinAmericaSpain 20284msoEncodingEBCDICMultilingualROECELatin2 870msoEncodingEBCDICRussian 20880msoEncodingEBCDICSerbianBulgarian 21025msoEncodingEBCDICSimplifiedChineseExtendedAndSimplifiedChinese 50935msoEncodingEBCDICThai 20838msoEncodingEBCDICTurkish 20905msoEncodingEBCDICTurkishLatin5 1026msoEncodingEBCDICUnitedKingdom 20285msoEncodingEBCDICUSCanada 37msoEncodingEBCDICUSCanadaAndJapanese 50931msoEncodingEBCDICUSCanadaAndTraditionalChinese 50937msoEncodingEUCChineseSimplifiedChinese 51936msoEncodingEUCJapanese 51932msoEncodingEUCKorean 51949msoEncodingEUCTaiwaneseTraditionalChinese 51950msoEncodingEuropa3 29001msoEncodingExtAlphaLowercase 21027msoEncodingGreek 1253msoEncodingGreekAutoDetect 51253msoEncodingHebrew 1255msoEncodingHZGBSimplifiedChinese 52936
Page 1086
msoEncodingIA5German 20106msoEncodingIA5IRV 20105msoEncodingIA5Norwegian 20108msoEncodingIA5Swedish 20107msoEncodingISCIIAssamese 57006msoEncodingISCIIBengali 57003msoEncodingISCIIDevanagari 57002msoEncodingISCIIGujarati 57010msoEncodingISCIIKannada 57008msoEncodingISCIIMalayalam 57009msoEncodingISCIIOriya 57007msoEncodingISCIIPunjabi 57011msoEncodingISCIITamil 57004msoEncodingISCIITelugu 57005msoEncodingISO2022CNSimplifiedChinese 50229msoEncodingISO2022CNTraditionalChinese 50227msoEncodingISO2022JPJISX02011989 50222msoEncodingISO2022JPJISX02021984 50221msoEncodingISO2022JPNoHalfwidthKatakana 50220msoEncodingISO2022KR 50225msoEncodingISO6937NonSpacingAccent 20269msoEncodingISO885915Latin9 28605msoEncodingISO88591Latin1 28591msoEncodingISO88592CentralEurope 28592msoEncodingISO88593Latin3 28593msoEncodingISO88594Baltic 28594msoEncodingISO88595Cyrillic 28595msoEncodingISO88596Arabic 28596msoEncodingISO88597Greek 28597msoEncodingISO88598Hebrew 28598msoEncodingISO88599Turkish 28599msoEncodingJapaneseAutoDetect 50932msoEncodingJapaneseShiftJIS 932
Page 1087
msoEncodingKOI8R 20866msoEncodingKOI8U 21866msoEncodingKorean 949msoEncodingKoreanAutoDetect 50949msoEncodingKoreanJohab 1361msoEncodingMacArabic 10004msoEncodingMacCroatia 10082msoEncodingMacCyrillic 10007msoEncodingMacGreek1 10006msoEncodingMacHebrew 10005msoEncodingMacIcelandic 10079msoEncodingMacJapanese 10001msoEncodingMacKorean 10003msoEncodingMacLatin2 10029msoEncodingMacRoman 10000msoEncodingMacRomania 10010msoEncodingMacSimplifiedChineseGB2312 10008msoEncodingMacTraditionalChineseBig5 10002msoEncodingMacTurkish 10081msoEncodingMacUkraine 10017msoEncodingOEMArabic 864msoEncodingOEMBaltic 775msoEncodingOEMCanadianFrench 863msoEncodingOEMCyrillic 855msoEncodingOEMCyrillicII 866msoEncodingOEMGreek437G 737msoEncodingOEMHebrew 862msoEncodingOEMIcelandic 861msoEncodingOEMModernGreek 869msoEncodingOEMMultilingualLatinI 850msoEncodingOEMMultilingualLatinII 852msoEncodingOEMNordic 865msoEncodingOEMPortuguese 860
Page 1088
msoEncodingOEMTurkish 857msoEncodingOEMUnitedStates 437msoEncodingSimplifiedChineseAutoDetect 50936msoEncodingSimplifiedChineseGBK 936msoEncodingT61 20261msoEncodingTaiwanCNS 20000msoEncodingTaiwanEten 20002msoEncodingTaiwanIBM5550 20003msoEncodingTaiwanTCA 20001msoEncodingTaiwanTeleText 20004msoEncodingTaiwanWang 20005msoEncodingThai 874msoEncodingTraditionalChineseAutoDetect 50950msoEncodingTraditionalChineseBig5 950msoEncodingTurkish 1254msoEncodingUnicodeBigEndian 1201msoEncodingUnicodeLittleEndian 1200msoEncodingUSASCII 20127msoEncodingUTF7 65000msoEncodingUTF8 65001msoEncodingVietnamese 1258msoEncodingWestern 1252
MsoExtraInfoMethod
Constant ValuemsoMethodGet 0msoMethodPost 1
MsoExtrusionColorType
Constant ValuemsoExtrusionColorAutomatic 1msoExtrusionColorCustom 2
Page 1089
msoExtrusionColorTypeMixed -2
MsoFarEastLineBreakLanguageID
Constant ValueMsoFarEastLineBreakLanguageJapanese 1041MsoFarEastLineBreakLanguageKorean 1042MsoFarEastLineBreakLanguageSimplifiedChinese 2052MsoFarEastLineBreakLanguageTraditionalChinese 1028
MsoFeatureInstall
Constant ValuemsoFeatureInstallNone 0msoFeatureInstallOnDemand 1msoFeatureInstallOnDemandWithUI 2
MsoFileDialogType
Constant ValuemsoFileDialogFilePicker 3msoFileDialogFolderPicker 4msoFileDialogOpen 1msoFileDialogSaveAs 2
MsoFileDialogView
Constant ValuemsoFileDialogViewDetails 2msoFileDialogViewLargeIcons 6msoFileDialogViewList 1msoFileDialogViewPreview 4msoFileDialogViewProperties 3msoFileDialogViewSmallIcons 7
Page 1090
msoFileDialogViewThumbnail 5msoFileDialogViewTiles 9msoFileDialogViewWebView 8
MsoFileFindListBy
Constant ValuemsoListbyName 1msoListbyTitle 2
MsoFileFindOptions
Constant ValuemsoOptionsAdd 2msoOptionsNew 1msoOptionsWithin 3
MsoFileFindSortBy
Constant ValuemsoFileFindSortbyAuthor 1msoFileFindSortbyDateCreated 2msoFileFindSortbyDateSaved 4msoFileFindSortbyFileName 5msoFileFindSortbyLastSavedBy 3msoFileFindSortbySize 6msoFileFindSortbyTitle 7
MsoFileFindView
Constant ValuemsoViewFileInfo 1msoViewPreview 2msoViewSummaryInfo 3
Page 1091
MsoFileNewAction
Constant ValuemsoCreateNewFile 1msoEditFile 0msoOpenFile 2
MsoFileNewSection
Constant ValuemsoBottomSection 4msoNew 1msoNewfromExistingFile 2msoNewfromTemplate 3msoOpenDocument 0
MsoFileType
Constant ValuemsoFileTypeAllFiles 1msoFileTypeBinders 6msoFileTypeCalendarItem 11msoFileTypeContactItem 12msoFileTypeDatabases 7msoFileTypeDataConnectionFiles 17msoFileTypeDesignerFiles 22msoFileTypeDocumentImagingFiles 20msoFileTypeExcelWorkbooks 4msoFileTypeJournalItem 14msoFileTypeMailItem 10msoFileTypeNoteItem 13msoFileTypeOfficeFiles 2msoFileTypeOutlookItems 9msoFileTypePhotoDrawFiles 16
Page 1092
msoFileTypePowerPointPresentations 5msoFileTypeProjectFiles 19msoFileTypePublisherFiles 18msoFileTypeTaskItem 15msoFileTypeTemplates 8msoFileTypeVisioFiles 21msoFileTypeWebPages 23msoFileTypeWordDocuments 3
MsoFillType
Constant ValuemsoFillBackground 5msoFillGradient 3msoFillMixed -2msoFillPatterned 2msoFillPicture 6msoFillSolid 1msoFillTextured 4
MsoFilterComparison
Constant ValuemsoFilterComparisonContains 8msoFilterComparisonEqual 0msoFilterComparisonGreaterThan 3msoFilterComparisonGreaterThanEqual 5msoFilterComparisonIsBlank 6msoFilterComparisonIsNotBlank 7msoFilterComparisonLessThan 2msoFilterComparisonLessThanEqual 4msoFilterComparisonNotContains 9msoFilterComparisonNotEqual 1
Page 1093
MsoFilterConjunction
Constant ValuemsoFilterConjunctionAnd 0msoFilterConjunctionOr 1
MsoFlipCmd
Constant ValuemsoFlipHorizontal 0msoFlipVertical 1
MsoGradientColorType
Constant ValuemsoGradientColorMixed -2msoGradientOneColor 1msoGradientPresetColors 3msoGradientTwoColors 2
MsoGradientStyle
Constant ValuemsoGradientDiagonalDown 4msoGradientDiagonalUp 3msoGradientFromCenter 7msoGradientFromCorner 5msoGradientFromTitle 6msoGradientHorizontal 1msoGradientMixed -2msoGradientVertical 2
MsoHorizontalAnchor
Page 1094
Constant ValuemsoAnchorCenter 2msoAnchorNone 1msoHorizontalAnchorMixed -2
MsoHTMLProjectOpen
Constant ValuemsoHTMLProjectOpenSourceView 1msoHTMLProjectOpenTextView 2
MsoHTMLProjectState
Constant ValuemsoHTMLProjectStateDocumentLocked 1msoHTMLProjectStateDocumentProjectUnlocked 3msoHTMLProjectStateProjectLocked 2
MsoHyperlinkType
Constant ValuemsoHyperlinkInlineShape 2msoHyperlinkRange 0msoHyperlinkShape 1
MsoIconType
Constant ValuemsoIconAlert 2msoIconAlertCritical 7msoIconAlertInfo 4msoIconAlertQuery 6msoIconAlertWarning 5msoIconNone 0
Page 1095
msoIconTip 3
MsoLanguageID
Constant ValuemsoLanguageIDAfrikaans 1078msoLanguageIDAlbanian 1052msoLanguageIDAmharic 1118msoLanguageIDArabic 1025msoLanguageIDArabicAlgeria 5121msoLanguageIDArabicBahrain 15361msoLanguageIDArabicEgypt 3073msoLanguageIDArabicIraq 2049msoLanguageIDArabicJordan 11265msoLanguageIDArabicKuwait 13313msoLanguageIDArabicLebanon 12289msoLanguageIDArabicLibya 4097msoLanguageIDArabicMorocco 6145msoLanguageIDArabicOman 8193msoLanguageIDArabicQatar 16385msoLanguageIDArabicSyria 10241msoLanguageIDArabicTunisia 7169msoLanguageIDArabicUAE 14337msoLanguageIDArabicYemen 9217msoLanguageIDArmenian 1067msoLanguageIDAssamese 1101msoLanguageIDAzeriCyrillic 2092msoLanguageIDAzeriLatin 1068msoLanguageIDBasque 1069msoLanguageIDBelgianDutch 2067msoLanguageIDBelgianFrench 2060msoLanguageIDBengali 1093msoLanguageIDBosnian 4122
Page 1096
msoLanguageIDBrazilianPortuguese 1046msoLanguageIDBulgarian 1026msoLanguageIDBurmese 1109msoLanguageIDByelorussian 1059msoLanguageIDCatalan 1027msoLanguageIDCherokee 1116msoLanguageIDChineseHongKong 3076msoLanguageIDChineseHongKongSAR 3076msoLanguageIDChineseMacao 5124msoLanguageIDChineseMacaoSAR 5124msoLanguageIDChineseSingapore 4100msoLanguageIDCroatian 1050msoLanguageIDCzech 1029msoLanguageIDDanish 1030msoLanguageIDDivehi 1125msoLanguageIDDutch 1043msoLanguageIDDzongkhaBhutan 2129msoLanguageIDEdo 1126msoLanguageIDEnglishAUS 3081msoLanguageIDEnglishBelize 10249msoLanguageIDEnglishCanadian 4105msoLanguageIDEnglishCaribbean 9225msoLanguageIDEnglishIndonesia 14345msoLanguageIDEnglishIreland 6153msoLanguageIDEnglishJamaica 8201msoLanguageIDEnglishNewZealand 5129msoLanguageIDEnglishPhilippines 13321msoLanguageIDEnglishSouthAfrica 7177msoLanguageIDEnglishTrinidad 11273msoLanguageIDEnglishTrinidadTobago 11273msoLanguageIDEnglishUK 2057msoLanguageIDEnglishUS 1033msoLanguageIDEnglishZimbabwe 12297
Page 1097
msoLanguageIDEstonian 1061msoLanguageIDFaeroese 1080msoLanguageIDFarsi 1065msoLanguageIDFilipino 1124msoLanguageIDFinnish 1035msoLanguageIDFrench 1036msoLanguageIDFrenchCameroon 11276msoLanguageIDFrenchCanadian 3084msoLanguageIDFrenchCotedIvoire 12300msoLanguageIDFrenchHaiti 15372msoLanguageIDFrenchLuxembourg 5132msoLanguageIDFrenchMali 13324msoLanguageIDFrenchMonaco 6156msoLanguageIDFrenchMorocco 14348msoLanguageIDFrenchReunion 8204msoLanguageIDFrenchSenegal 10252msoLanguageIDFrenchWestIndies 7180msoLanguageIDFrenchZaire 9228msoLanguageIDFrisianNetherlands 1122msoLanguageIDFulfulde 1127msoLanguageIDGaelicIreland 2108msoLanguageIDGaelicScotland 1084msoLanguageIDGalician 1110msoLanguageIDGeorgian 1079msoLanguageIDGerman 1031msoLanguageIDGermanAustria 3079msoLanguageIDGermanLiechtenstein 5127msoLanguageIDGermanLuxembourg 4103msoLanguageIDGreek 1032msoLanguageIDGuarani 1140msoLanguageIDGujarati 1095msoLanguageIDHausa 1128msoLanguageIDHawaiian 1141
Page 1098
msoLanguageIDHebrew 1037msoLanguageIDHindi 1081msoLanguageIDHungarian 1038msoLanguageIDIbibio 1129msoLanguageIDIcelandic 1039msoLanguageIDIgbo 1136msoLanguageIDIndonesian 1057msoLanguageIDInuktitut 1117msoLanguageIDItalian 1040msoLanguageIDJapanese 1041msoLanguageIDKannada 1099msoLanguageIDKanuri 1137msoLanguageIDKashmiri 1120msoLanguageIDKashmiriDevanagari 2144msoLanguageIDKashmiriIndia 2144msoLanguageIDKazakh 1087msoLanguageIDKhmer 1107msoLanguageIDKirghiz 1088msoLanguageIDKonkani 1111msoLanguageIDKorean 1042msoLanguageIDKyrgyz 1088msoLanguageIDLao 1108msoLanguageIDLatin 1142msoLanguageIDLatvian 1062msoLanguageIDLithuanian 1063msoLanguageIDMacedonian 1071msoLanguageIDMalayalam 1100msoLanguageIDMalayBruneiDarussalam 2110msoLanguageIDMalaysian 1086msoLanguageIDMaltese 1082msoLanguageIDManipuri 1112msoLanguageIDMaori 1153msoLanguageIDMarathi 1102
Page 1099
msoLanguageIDMexicanSpanish 2058msoLanguageIDMixed -2msoLanguageIDMongolian 1104msoLanguageIDNepali 1121msoLanguageIDNone 0msoLanguageIDNoProofing 1024msoLanguageIDNorwegianBokmol 1044msoLanguageIDNorwegianNynorsk 2068msoLanguageIDOriya 1096msoLanguageIDOromo 1138msoLanguageIDPashto 1123msoLanguageIDPolish 1045msoLanguageIDPortuguese 2070msoLanguageIDPunjabi 1094msoLanguageIDRhaetoRomanic 1047msoLanguageIDRomanian 1048msoLanguageIDRomanianMoldova 2072msoLanguageIDRussian 1049msoLanguageIDRussianMoldova 2073msoLanguageIDSamiLappish 1083msoLanguageIDSanskrit 1103msoLanguageIDSerbianCyrillic 3098msoLanguageIDSerbianLatin 2074msoLanguageIDSesotho 1072msoLanguageIDSimplifiedChinese 2052msoLanguageIDSindhi 1113msoLanguageIDSindhiPakistan 2137msoLanguageIDSinhalese 1115msoLanguageIDSlovak 1051msoLanguageIDSlovenian 1060msoLanguageIDSomali 1143msoLanguageIDSorbian 1070msoLanguageIDSpanish 1034
Page 1100
msoLanguageIDSpanishArgentina 11274msoLanguageIDSpanishBolivia 16394msoLanguageIDSpanishChile 13322msoLanguageIDSpanishColombia 9226msoLanguageIDSpanishCostaRica 5130msoLanguageIDSpanishDominicanRepublic 7178msoLanguageIDSpanishEcuador 12298msoLanguageIDSpanishElSalvador 17418msoLanguageIDSpanishGuatemala 4106msoLanguageIDSpanishHonduras 18442msoLanguageIDSpanishModernSort 3082msoLanguageIDSpanishNicaragua 19466msoLanguageIDSpanishPanama 6154msoLanguageIDSpanishParaguay 15370msoLanguageIDSpanishPeru 10250msoLanguageIDSpanishPuertoRico 20490msoLanguageIDSpanishUruguay 14346msoLanguageIDSpanishVenezuela 8202msoLanguageIDSutu 1072msoLanguageIDSwahili 1089msoLanguageIDSwedish 1053msoLanguageIDSwedishFinland 2077msoLanguageIDSwissFrench 4108msoLanguageIDSwissGerman 2055msoLanguageIDSwissItalian 2064msoLanguageIDSyriac 1114msoLanguageIDTajik 1064msoLanguageIDTamazight 1119msoLanguageIDTamazightLatin 2143msoLanguageIDTamil 1097msoLanguageIDTatar 1092msoLanguageIDTelugu 1098msoLanguageIDThai 1054
Page 1101
msoLanguageIDTibetan 1105msoLanguageIDTigrignaEritrea 2163msoLanguageIDTigrignaEthiopic 1139msoLanguageIDTraditionalChinese 1028msoLanguageIDTsonga 1073msoLanguageIDTswana 1074msoLanguageIDTurkish 1055msoLanguageIDTurkmen 1090msoLanguageIDUkrainian 1058msoLanguageIDUrdu 1056msoLanguageIDUzbekCyrillic 2115msoLanguageIDUzbekLatin 1091msoLanguageIDVenda 1075msoLanguageIDVietnamese 1066msoLanguageIDWelsh 1106msoLanguageIDXhosa 1076msoLanguageIDYi 1144msoLanguageIDYiddish 1085msoLanguageIDYoruba 1130msoLanguageIDZulu 1077
MsoLastModified
Constant ValuemsoLastModifiedAnyTime 7msoLastModifiedLastMonth 5msoLastModifiedLastWeek 3msoLastModifiedThisMonth 6msoLastModifiedThisWeek 4msoLastModifiedToday 2msoLastModifiedYesterday 1
MsoLineDashStyle
Page 1102
Constant ValuemsoLineDash 4msoLineDashDot 5msoLineDashDotDot 6msoLineDashStyleMixed -2msoLineLongDash 7msoLineLongDashDot 8msoLineRoundDot 3msoLineSolid 1msoLineSquareDot 2
MsoLineStyle
Constant ValuemsoLineSingle 1msoLineStyleMixed -2msoLineThickBetweenThin 5msoLineThickThin 4msoLineThinThick 3msoLineThinThin 2
MsoMenuAnimation
Constant ValuemsoMenuAnimationNone 0msoMenuAnimationRandom 1msoMenuAnimationSlide 3msoMenuAnimationUnfold 2
MsoMixedType
Constant ValuemsoIntegerMixed 32768msoSingleMixed -2147483648
Page 1103
MsoModeType
Constant ValuemsoModeAutoDown 1msoModeModal 0msoModeModeless 2
MsoMoveRow
Constant ValuemsoMoveRowFirst -4msoMoveRowNbr -1msoMoveRowNext -2msoMoveRowPrev -3
MsoOLEMenuGroup
Constant ValuemsoOLEMenuGroupContainer 2msoOLEMenuGroupEdit 1msoOLEMenuGroupFile 0msoOLEMenuGroupHelp 5msoOLEMenuGroupNone -1msoOLEMenuGroupObject 3msoOLEMenuGroupWindow 4
MsoOrgChartLayoutType
Constant ValuemsoOrgChartLayoutBothHanging 2msoOrgChartLayoutLeftHanging 3msoOrgChartLayoutMixed -2msoOrgChartLayoutRightHanging 4msoOrgChartLayoutStandard 1
Page 1104
MsoOrgChartOrientation
Constant ValuemsoOrgChartOrientationMixed -2msoOrgChartOrientationVertical 1
MsoOrientation
Constant ValuemsoOrientationHorizontal 1msoOrientationMixed -2msoOrientationVertical 2
MsoPatternType
Constant ValuemsoPattern10Percent 2msoPattern20Percent 3msoPattern25Percent 4msoPattern30Percent 5msoPattern40Percent 6msoPattern50Percent 7msoPattern5Percent 1msoPattern60Percent 8msoPattern70Percent 9msoPattern75Percent 10msoPattern80Percent 11msoPattern90Percent 12msoPatternDarkDownwardDiagonal 15msoPatternDarkHorizontal 13msoPatternDarkUpwardDiagonal 16msoPatternDarkVertical 14msoPatternDashedDownwardDiagonal 28msoPatternDashedHorizontal 32
Page 1105
msoPatternDashedUpwardDiagonal 27msoPatternDashedVertical 31msoPatternDiagonalBrick 40msoPatternDivot 46msoPatternDottedDiamond 24msoPatternDottedGrid 45msoPatternHorizontalBrick 35msoPatternLargeCheckerBoard 36msoPatternLargeConfetti 33msoPatternLargeGrid 34msoPatternLightDownwardDiagonal 21msoPatternLightHorizontal 19msoPatternLightUpwardDiagonal 22msoPatternLightVertical 20msoPatternMixed -2msoPatternNarrowHorizontal 30msoPatternNarrowVertical 29msoPatternOutlinedDiamond 41msoPatternPlaid 42msoPatternShingle 47msoPatternSmallCheckerBoard 17msoPatternSmallConfetti 37msoPatternSmallGrid 23msoPatternSolidDiamond 39msoPatternSphere 43msoPatternTrellis 18msoPatternWave 48msoPatternWeave 44msoPatternWideDownwardDiagonal 25msoPatternWideUpwardDiagonal 26msoPatternZigZag 38
MsoPermission
Page 1106
Constant ValuemsoPermissionChange 15msoPermissionEdit 2msoPermissionExtract 8msoPermissionFullControl 64msoPermissionObjModel 32msoPermissionPrint 16msoPermissionRead 1msoPermissionSave 4msoPermissionView 1
MsoPictureColorType
Constant ValuemsoPictureAutomatic 1msoPictureBlackAndWhite 3msoPictureGrayscale 2msoPictureMixed -2msoPictureWatermark 4
MsoPresetExtrusionDirection
Constant ValuemsoExtrusionBottom 2msoExtrusionBottomLeft 3msoExtrusionBottomRight 1msoExtrusionLeft 6msoExtrusionNone 5msoExtrusionRight 4msoExtrusionTop 8msoExtrusionTopLeft 9msoExtrusionTopRight 7msoPresetExtrusionDirectionMixed -2
Page 1107
MsoPresetGradientType
Constant ValuemsoGradientBrass 20msoGradientCalmWater 8msoGradientChrome 21msoGradientChromeII 22msoGradientDaybreak 4msoGradientDesert 6msoGradientEarlySunset 1msoGradientFire 9msoGradientFog 10msoGradientGold 18msoGradientGoldII 19msoGradientHorizon 5msoGradientLateSunset 2msoGradientMahogany 15msoGradientMoss 11msoGradientNightfall 3msoGradientOcean 7msoGradientParchment 14msoGradientPeacock 12msoGradientRainbow 16msoGradientRainbowII 17msoGradientSapphire 24msoGradientSilver 23msoGradientWheat 13msoPresetGradientMixed -2
MsoPresetLightingDirection
Constant ValuemsoLightingBottom 8
Page 1108
msoLightingBottomLeft 7msoLightingBottomRight 9msoLightingLeft 4msoLightingNone 5msoLightingRight 6msoLightingTop 2msoLightingTopLeft 1msoLightingTopRight 3msoPresetLightingDirectionMixed -2
MsoPresetLightingSoftness
Constant ValuemsoLightingBright 3msoLightingDim 1msoLightingNormal 2msoPresetLightingSoftnessMixed -2
MsoPresetMaterial
Constant ValuemsoMaterialMatte 1msoMaterialMetal 3msoMaterialPlastic 2msoMaterialWireFrame 4msoPresetMaterialMixed -2
MsoPresetTextEffect
Constant ValuemsoTextEffect1 0msoTextEffect10 9msoTextEffect11 10msoTextEffect12 11
Page 1109
msoTextEffect13 12msoTextEffect14 13msoTextEffect15 14msoTextEffect16 15msoTextEffect17 16msoTextEffect18 17msoTextEffect19 18msoTextEffect2 1msoTextEffect20 19msoTextEffect21 20msoTextEffect22 21msoTextEffect23 22msoTextEffect24 23msoTextEffect25 24msoTextEffect26 25msoTextEffect27 26msoTextEffect28 27msoTextEffect29 28msoTextEffect3 2msoTextEffect30 29msoTextEffect4 3msoTextEffect5 4msoTextEffect6 5msoTextEffect7 6msoTextEffect8 7msoTextEffect9 8msoTextEffectMixed -2
MsoPresetTextEffectShape
Constant ValuemsoTextEffectShapeArchDownCurve 10msoTextEffectShapeArchDownPour 14
Page 1110
msoTextEffectShapeArchUpCurve 9msoTextEffectShapeArchUpPour 13msoTextEffectShapeButtonCurve 12msoTextEffectShapeButtonPour 16msoTextEffectShapeCanDown 20msoTextEffectShapeCanUp 19msoTextEffectShapeCascadeDown 40msoTextEffectShapeCascadeUp 39msoTextEffectShapeChevronDown 6msoTextEffectShapeChevronUp 5msoTextEffectShapeCircleCurve 11msoTextEffectShapeCirclePour 15msoTextEffectShapeCurveDown 18msoTextEffectShapeCurveUp 17msoTextEffectShapeDeflate 26msoTextEffectShapeDeflateBottom 28msoTextEffectShapeDeflateInflate 31msoTextEffectShapeDeflateInflateDeflate 32msoTextEffectShapeDeflateTop 30msoTextEffectShapeDoubleWave1 23msoTextEffectShapeDoubleWave2 24msoTextEffectShapeFadeDown 36msoTextEffectShapeFadeLeft 34msoTextEffectShapeFadeRight 33msoTextEffectShapeFadeUp 35msoTextEffectShapeInflate 25msoTextEffectShapeInflateBottom 27msoTextEffectShapeInflateTop 29msoTextEffectShapeMixed -2msoTextEffectShapePlainText 1msoTextEffectShapeRingInside 7msoTextEffectShapeRingOutside 8msoTextEffectShapeSlantDown 38
Page 1111
msoTextEffectShapeSlantUp 37msoTextEffectShapeStop 2msoTextEffectShapeTriangleDown 4msoTextEffectShapeTriangleUp 3msoTextEffectShapeWave1 21msoTextEffectShapeWave2 22
MsoPresetTexture
Constant ValuemsoPresetTextureMixed -2msoTextureBlueTissuePaper 17msoTextureBouquet 20msoTextureBrownMarble 11msoTextureCanvas 2msoTextureCork 21msoTextureDenim 3msoTextureFishFossil 7msoTextureGranite 12msoTextureGreenMarble 9msoTextureMediumWood 24msoTextureNewsprint 13msoTextureOak 23msoTexturePaperBag 6msoTexturePapyrus 1msoTextureParchment 15msoTexturePinkTissuePaper 18msoTexturePurpleMesh 19msoTextureRecycledPaper 14msoTextureSand 8msoTextureStationery 16msoTextureWalnut 22msoTextureWaterDroplets 5
Page 1112
msoTextureWhiteMarble 10msoTextureWovenMat 4
MsoPresetThreeDFormat
Constant ValuemsoPresetThreeDFormatMixed -2msoThreeD1 1msoThreeD10 10msoThreeD11 11msoThreeD12 12msoThreeD13 13msoThreeD14 14msoThreeD15 15msoThreeD16 16msoThreeD17 17msoThreeD18 18msoThreeD19 19msoThreeD2 2msoThreeD20 20msoThreeD3 3msoThreeD4 4msoThreeD5 5msoThreeD6 6msoThreeD7 7msoThreeD8 8msoThreeD9 9
MsoRelativeNodePosition
Constant ValuemsoAfterLastSibling 4msoAfterNode 2msoBeforeFirstSibling 3
Page 1113
msoBeforeNode 1
MsoScaleFrom
Constant ValuemsoScaleFromBottomRight 2msoScaleFromMiddle 1msoScaleFromTopLeft 0
MsoScreenSize
Constant ValuemsoScreenSize1024x768 4msoScreenSize1152x882 5msoScreenSize1152x900 6msoScreenSize1280x1024 7msoScreenSize1600x1200 8msoScreenSize1800x1440 9msoScreenSize1920x1200 10msoScreenSize544x376 0msoScreenSize640x480 1msoScreenSize720x512 2msoScreenSize800x600 3
MsoScriptLanguage
Constant ValuemsoScriptLanguageASP 3msoScriptLanguageJava 1msoScriptLanguageOther 4msoScriptLanguageVisualBasic 2
MsoScriptLocation
Page 1114
Constant ValuemsoScriptLocationInBody 2msoScriptLocationInHead 1
MsoSearchIn
Constant ValuemsoSearchInCustom 3msoSearchInMyComputer 0msoSearchInMyNetworkPlaces 2msoSearchInOutlook 1
MsoSegmentType
Constant ValuemsoSegmentCurve 1msoSegmentLine 0
MsoShadowType
Constant ValuemsoShadow1 1msoShadow10 10msoShadow11 11msoShadow12 12msoShadow13 13msoShadow14 14msoShadow15 15msoShadow16 16msoShadow17 17msoShadow18 18msoShadow19 19msoShadow2 2msoShadow20 20
Page 1115
msoShadow3 3msoShadow4 4msoShadow5 5msoShadow6 6msoShadow7 7msoShadow8 8msoShadow9 9msoShadowMixed -2
MsoShapeType
Constant ValuemsoAutoShape 1msoCallout 2msoCanvas 20msoChart 3msoComment 4msoDiagram 21msoEmbeddedOLEObject 7msoFormControl 8msoFreeform 5msoGroup 6msoInk 22msoInkComment 23msoLine 9msoLinkedOLEObject 10msoLinkedPicture 11msoMedia 16msoOLEControlObject 12msoPicture 13msoPlaceholder 14msoScriptAnchor 18msoShapeTypeMixed -2
Page 1116
msoTable 19msoTextBox 17msoTextEffect 15
MsoSharedWorkspaceTaskPriority
Constant ValuemsoSharedWorkspaceTaskPriorityHigh 1msoSharedWorkspaceTaskPriorityLow 3msoSharedWorkspaceTaskPriorityNormal 2
MsoSharedWorkspaceTaskStatus
Constant ValuemsoSharedWorkspaceTaskStatusCompleted 3msoSharedWorkspaceTaskStatusDeferred 4msoSharedWorkspaceTaskStatusInProgress 2msoSharedWorkspaceTaskStatusNotStarted 1msoSharedWorkspaceTaskStatusWaiting 5
MsoSortBy
Constant ValuemsoSortByFileName 1msoSortByFileType 3msoSortByLastModified 4msoSortByNone 5msoSortBySize 2
MsoSortOrder
Constant ValuemsoSortOrderAscending 1msoSortOrderDescending 2
Page 1117
MsoSyncAvailableType
Constant ValuemsoSyncAvailableAnywhere 2msoSyncAvailableNone 0msoSyncAvailableOffline 1
MsoSyncCompareType
Constant ValuemsoSyncCompareAndMerge 0msoSyncCompareSideBySide 1
MsoSyncConflictResolutionType
Constant ValuemsoSyncConflictClientWins 0msoSyncConflictMerge 2msoSyncConflictServerWins 1
MsoSyncErrorType
Constant ValuemsoSyncErrorCouldNotCompare 13msoSyncErrorCouldNotConnect 2msoSyncErrorCouldNotOpen 11msoSyncErrorCouldNotResolve 14msoSyncErrorCouldNotUpdate 12msoSyncErrorFileInUse 6msoSyncErrorFileNotFound 4msoSyncErrorFileTooLarge 5msoSyncErrorNone 0msoSyncErrorNoNetwork 15msoSyncErrorOutOfSpace 3
Page 1118
msoSyncErrorUnauthorizedUser 1msoSyncErrorUnknown 16msoSyncErrorUnknownDownload 10msoSyncErrorUnknownUpload 9msoSyncErrorVirusDownload 8msoSyncErrorVirusUpload 7
MsoSyncEventType
Constant ValuemsoSyncEventDownloadFailed 2msoSyncEventDownloadInitiated 0msoSyncEventDownloadNoChange 6msoSyncEventDownloadSucceeded 1msoSyncEventOffline 7msoSyncEventUploadFailed 5msoSyncEventUploadInitiated 3msoSyncEventUploadSucceeded 4
MsoSyncStatusType
Constant ValuemsoSyncStatusConflict 4msoSyncStatusError 6msoSyncStatusLatest 1msoSyncStatusLocalChanges 3msoSyncStatusNewerAvailable 2msoSyncStatusNoSharedWorkspace 0msoSyncStatusSuspended 5
MsoSyncVersionType
Constant ValuemsoSyncVersionLastViewed 0
Page 1119
msoSyncVersionServer 1
MsoTargetBrowser
Constant ValuemsoTargetBrowserIE4 2msoTargetBrowserIE5 3msoTargetBrowserIE6 4msoTargetBrowserV3 0msoTargetBrowserV4 1
MsoTextEffectAlignment
Constant ValuemsoTextEffectAlignmentCentered 2msoTextEffectAlignmentLeft 1msoTextEffectAlignmentLetterJustify 4msoTextEffectAlignmentMixed -2msoTextEffectAlignmentRight 3msoTextEffectAlignmentStretchJustify 6msoTextEffectAlignmentWordJustify 5
MsoTextOrientation
Constant ValuemsoTextOrientationDownward 3msoTextOrientationHorizontal 1msoTextOrientationHorizontalRotatedFarEast 6msoTextOrientationMixed -2msoTextOrientationUpward 2msoTextOrientationVertical 5msoTextOrientationVerticalFarEast 4
MsoTextureType
Page 1120
Constant ValuemsoTexturePreset 1msoTextureTypeMixed -2msoTextureUserDefined 2
MsoTriState
Constant ValuemsoCTrue 1msoFalse 0msoTriStateMixed -2msoTriStateToggle -3msoTrue -1
MsoVerticalAnchor
Constant ValuemsoAnchorBottom 4msoAnchorBottomBaseLine 5msoAnchorMiddle 3msoAnchorTop 1msoAnchorTopBaseline 2msoVerticalAnchorMixed -2
MsoWizardActType
Constant ValuemsoWizardActActive 1msoWizardActInactive 0msoWizardActResume 3msoWizardActSuspend 2
MsoWizardMsgType
Page 1121
Constant ValuemsoWizardMsgLocalStateOff 2msoWizardMsgLocalStateOn 1msoWizardMsgResuming 5msoWizardMsgShowHelp 3msoWizardMsgSuspending 4
MsoZOrderCmd
Constant ValuemsoBringForward 2msoBringInFrontOfText 4msoBringToFront 0msoSendBackward 3msoSendBehindText 5msoSendToBack 1
Page 1122
ReturninganObjectfromaCollectionTheItempropertyreturnsasingleobjectfromacollection.ThefollowingexamplesetsthecmdbarvariabletoaCommandBarobjectthatrepresentsthefirstcommandbarintheCommandBarscollection.
Setcmdbar=CommandBars.Item(1)
TheItempropertyisthedefaultpropertyformostcollections,soyoucanwritethesamestatementmoreconciselybyomittingtheItemkeyword.
Setcmdbar=CommandBars(1)
Formoreinformationaboutaspecificcollection,seetheHelptopicforthecollectionortheItempropertyforthecollection.