vb6替换WinWord标头中的文本

编程入门 行业动态 更新时间:2024-10-25 20:27:43
本文介绍了vb6替换WinWord标头中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 请有人帮忙。我有一个客户端使用VB6构建的应用程序。在不同阶段,这将运行Word文档模板,并使用数据库中的信息替换各种字段(这只是背景信息)。 他们最近对标题进行了更改,所以现在标题包含需要替换的信息。 我搜索过CodeProject,以及网上相当广泛但无法找到有效的解决方案... 我能想出的最好的是下面的代码(它不会崩溃,但它找不到文本,即使它在文件中)...

Hi all, Please can someone help. I have a client using a VB6 built app. At various stages this runs through a Word Document Template and replaces various fields with info from a Database (this is just background info). They have recently made changes to the header, so now the header contains information that needs to be replaced. I have searched CodeProject, as well as quite extensively on the net and can't find a valid solution... The best I can come up with is the below code (which doesn't crash, but it doesn't find the text, even though it IS in the file)...

ActiveDocument.StoryRanges(wdPrimaryHeaderStory).Select Do While ActiveDocument.StoryRanges(wdPrimaryHeaderStory).Find.Execute("<User_Branch_Tel>") = True ActiveDocument.StoryRanges(wdPrimaryHeaderStory).Cut ActiveDocument.StoryRanges(wdPrimaryHeaderStory).InsertAfter "Test" Loop

推荐答案

大家好, 经过多次坚持,我找到了答案: Hi everyone, After lots of persistence I found the answer: Set Range = NewApp.ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range Do While Range.Find.Execute("TextToSearchFor") = True Range.Cut Range.InsertAfter "TextToReplace" Loop

谢谢......

Thanks...

更多推荐

vb6替换WinWord标头中的文本

本文发布于:2023-11-09 15:58:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572800.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   WinWord   标头中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!