如何从 INCLUDETEXT 中识别字段?

发布时间:2021-02-25 10:05

使用 VBA Microsoft Word,我处理使用大量 INCLUDETEXT 和 MERGEFIELD 的文档。

我想识别主文档中的 MERGEFIELD 字段和 INCLUDETEXT 文档中的 MERGEFIELD 字段。

@Slf4j
@Configuration
public class WebClientConfig {

    @Bean
    WebClient authWebClient(ClientRegistrationRepository clientRegistrations,
                                    OAuth2AuthorizedClientRepository authorizedClients,
                                    PasswordResolver passwordResolver) {
        var clientRegistration = clientRegistrations.findByRegistrationId("myApp");
        log.info("Before client secret is {}",clientRegistration.getClientSecret());
        var clientSecret = passwordResolver.resolve(clientRegistration.getClientSecret());
        log.info("Resolved client secret is {}", clientSecret);
        var enrichedClientRegistration=ClientRegistration.withClientRegistration(clientRegistration)
                .clientSecret(clientSecret)
                .build();
        log.info("After client secret is {}",clientRegistrations.findByRegistrationId("myApp").getClientSecret());
        var oauth = new ServletOAuth2AuthorizedClientExchangeFilterFunction(clientRegistrations, authorizedClients);
        oauth.setDefaultClientRegistrationId("myApp");

        return WebClient.builder()
                .apply(oauth.oauth2Configuration())
                .build();
    }
}

Sub listAllFields() Dim fld As Field Dim oStory As Object For Each oStory In ActiveDocument.StoryRanges For Each fld In oStory.Fields Debug.Print fld.Type, fld.Code.Text, fld.Parent.Name Next fld Next oStory End Sub 始终返回主文档名称。

例如,我的主文档中有 2 个字段:1 个 INCLUDETEXT 和 1 个 MERGEFIELD。在随附的文件中,我有 3 个 MERGEFIELD。当我用我建议的代码枚举主要文档的所有字段时,我将访问 5 个字段。如何知道 MERGEFIELD 字段是来自主文档还是继承自 INCLUDETEXT 包含的文档?

回答1