word moveend moveend - 电脑|办公 - 电脑办公-杀毒安全-网络-V3学习网
微商网
 
 
导航:首页 |电脑|办公|正文

word moveend moveend

时间:2020-07-18 08:16:51
关于Word中 的VBA 编程 解决你的“顺便问下" Sub Macro1()Dim strText As StringstrText = "建立反对撒客里空的龙卷风"Selection Ty
作者:

word moveend

关于Word中 的VBA 编程

解决你的“顺便问下".....Sub Macro1()Dim strText As StringstrText = "建立反对撒客里空的龙卷风"Selection.TypeText strTextSelection.MoveStart Unit:=wdLine, Count:=-1Selection.MoveEnd Unit:=wdCharacter, Count:=-1 * (Len(Selection.Text) - 4)Selection.MoveStart Unit:=wdCharacter, Count:=3Selection.Font.Bold = TrueMsgBox Selection.TextEnd Sub

如何将网页文件导出到word中

在做项目时碰到的 function OpenWord(){ Layer1.style.border=0 word = new ActiveXObject("Word.Application"); word.Application.Visible = true; var mydoc=word.Documents.Add("",0,1); myRange =mydoc.Range(0,1) var sel=Layer1.document.body.createTextRange() sel.select() Layer1.document.execCommand("Copy") sel.moveEnd("character") myRange.Paste(); location.reload() word.ActiveWindow.ActivePane.View.Type=9 }

vc搜索word和pdf文档,可否加入算法

#include "stdafx.h"#pragma warning(disable:4259)#import "C:\\Program Files\\Common Files\\Microsoft Shared\\Office11\\MSO.DLL" rename("IAccessible", "msoIAccessible")using namespace Office;#import "C:\\Program Files\\Common Files\\Microsoft Shared\\VBA\\VBA6\\VBE6EXT.OLB"//using namespace VBIDE; #import "d:\\Program Files\\Microsoft Office\\OFFICE11\\MSWORD.OLB" rename("ExitWindows","WordExitWindows")using namespace Word;#include #include using namespace std;int _tmain(int argc, _TCHAR* argv[]){CoInitialize(0);{_ApplicationPtr m_WordPtr;DocumentsPtr m_DocsPtr;_DocumentPtr m_DocPtr;HRESULT hr;try{//CLSID sid;//CLSIDFromProgID(L"word.application",&sid);hr=m_WordPtr.CreateInstance(__uuidof(Application)); m_WordPtr->put_Visible(VARIANT_TRUE);m_DocPtr=m_WordPtr->Documents->Add();LPSTR a = "c:\\22.doc";CComBSTR b = a;BSTR c = b.m_str;VARIANT va;va.vt = VT_BSTR;va.bstrVal = c;m_WordPtr->Documents->Open(&va);SelectionPtr sel=m_WordPtr->GetSelection();sel->TypeText(_bstr_t("sadsaS12as"));sel->MoveEnd();InlineShapePtr sh=sel->GetInlineShapes()->AddPicture(_bstr_t("c:\\1.jpg"));sel->SetRange(1,2);//sel->TypeText(_bstr_t("!!!!!!!"));_bstr_t text=sel->GetText();char *s=_com_util::ConvertBSTRToString(text);coutTablesPtr tables = sel->GetTables();TablePtr table = tables->Add(sel->GetRange(), 2, 5);BordersPtr bords = table->GetBorders();bords->PutOutsideLineStyle(wdLineStyleSingle);bords->PutOutsideLineWidth(wdLineWidth150pt);bords->PutInsideLineStyle(wdLineStyleSingle);for (int i = 1; i{for (int j = 1; j{table->Cell(i,j)->GetRange()->PutText("20");}}

用VB如何在WORD指定位置上插入文字?

在VB6.0中,操作word,使用它强大的查找、替换、删除、复制、翦切功能。

还可以把特定字符替换成图片。

有了它你就可以使用数据库中的内容或图片文件替换word文件中的特定字符。

只要把下列内容复制到写字板中,另存为SetWord.cls文件,然后在把它添加到工程中,就可以使用了。

VERSION 1.0 CLASS BEGIN MultiUse = -1 "True Persistable = 0 "NotPersistable DataBindingBehavior = 0 "vbNone DataSourceBehavior = 0 "vbNone MTSTransactionMode = 0 "NotAnMTSObject END Attribute VB_Name = "SetWord" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Private mywdapp As Word.Application Private mysel As Object"属性值的模块变量 Private C_TemplateDoc As String Private C_newDoc As String Private C_PicFile As String Private C_ErrMsg As Integer Public Event HaveError() Attribute HaveError.VB_Description = "出错时激发此事件.出错代码为ErrMsg属性""***************************************************************"ErrMsg代码:1-word没有安装 2 - 缺少参数 3 - 没权限写文件" 4 - 文件不存在""*************************************************************** Public Function ReplacePic(FindStr As String, Optional Time As Integer = 0) As Integer Attribute ReplacePic.VB_Description = "查找FindStr,并替换为PicFile所指向的图片文件,替换次数由time参数确定,为0时,替换所有""********************************************************************************" 从Word.Range对象mysel中查找所有FindStr,并替换为PicFile图像" 替换次数由time参数确定,为0时,替换所有"******************************************************************************** If Len(C_PicFile) = 0 Then C_ErrMsg = 2 Exit Function End If Dim i As Integer Dim findtxt As Boolean mysel.Find.ClearFormatting mysel.Find.Replacement.ClearFormatting With mysel.Find.Text = FindStr.Replacement.Text = "".Forward = True.Wrap = wdFindContinue.Format = False.MatchCase = False.MatchWholeWord = False.MatchByte = True.MatchWildcards = False.MatchSoundsLike = False.MatchAllWordForms = False End With mysel.HomeKey Unit:=wdStory findtxt = mysel.Find.Execute(Replace:=True) If Not findtxt Then ReplacePic = 0 Exit Function End If i = 1 Do While findtxt mysel.InlineShapes.AddPicture FileName:=C_PicFile If i = Time Then Exit Do i = i + 1 mysel.HomeKey Unit:=wdStory findtxt = mysel.Find.Execute(Replace:=True) Loop ReplacePic = i End Function Public Function FindThis(FindStr As String) As Boolean Attribute FindThis.VB_Description = "查找FindStr,如果模板中有FindStr则返回True" If Len(FindStr) = 0 Then C_ErrMsg = 2 Exit Function End If mysel.Find.ClearFormatting mysel.Find.Replacement.ClearFormatting With mysel.Find.Text = FindStr.Replacement.Text = "".Forward = True.Wrap = wdFindContinue.Format = False.MatchCase = False.MatchWholeWord = False.MatchByte = True.MatchWildcards = False.MatchSoundsLike = False.MatchAllWordForms = False End With mysel.HomeKey Unit:=wdStory FindThis = mysel.Find.Execute End Function Public Function ReplaceChar(FindStr As String, RepStr As String, Optional Time As Integer = 0) As Integer Attribute ReplaceChar.VB_Description = "查找FindStr,并替换为RepStr,替换次数由time参数确定,为0时,替换所有""********************************************************************************" 从Word.Range对象mysel中查找FindStr,并替换为RepStr" 替换次数由time参数确定,为0时,替换所有"******************************************************************************** Dim findtxt As Boolean If Len(FindStr) = 0 Then C_ErrMsg = 2 RaiseEvent HaveError Exit Function End If mysel.Find.ClearFormatting mysel.Find.Replacement.ClearFormatting With mysel.Find.Text = FindStr.Replacement.Text = RepStr.Forward = True.Wrap = wdFindContinue.Format = False.MatchCase = False.MatchWholeWord = False.MatchByte = True.MatchWildcards = False.MatchSoundsLike = False.MatchAllWordForms = False End With If Time > 0 Then For i = 1 To Time mysel.HomeKey Unit:=wdStory findtxt = mysel.Find.Execute(Replace:=wdReplaceOne) If Not findtxt Then Exit For Next If i = 1 And Not findtxt Then ReplaceChar = 0 Else ReplaceChar = i End If Else mysel.Find.Execute Replace:=wdReplaceAll End If End Function Public Function GetPic(PicData() As Byte, FileName As String) As Boolean Attribute GetPic.VB_Description = "把图像数据PicData,存为PicFile指定的文件""********************************************************************************" 把图像数据PicData,存为PicFile指定的文件"*********************************************...

大家还关注
    
阅读排行
推荐阅读