VB代码wordWord格式.doc
- 文档编号:1452376
- 上传时间:2023-04-30
- 格式:DOC
- 页数:10
- 大小:28KB
VB代码wordWord格式.doc
《VB代码wordWord格式.doc》由会员分享,可在线阅读,更多相关《VB代码wordWord格式.doc(10页珍藏版)》请在冰点文库上搜索。
dot="
C:
\temp.dot"
doc="
c:
\temp.doc"
Documents.OpenFileName:
=dot,_
ConfirmConversions:
=False,ReadOnly:
=True,AddToRecentFiles:
=False,_
PasswordDocument:
="
"
PasswordTemplate:
Revert:
WritePasswordDocument:
WritePasswordTemplate:
Format:
=_
0
Wrd.ActiveDocument.Close
Wrd.Documents.AddTemplate:
=dot,NewTemplate:
=False
'
结果系列操作
ActiveDocument.SaveAsFileName:
=doc,FileFormat:
=wdFormatDocument,_
LockComments:
=False,Password:
AddToRecentFiles:
=True,WritePassword_
:
ReadOnlyRecommended:
=False,EmbedTrueTypeFonts:
SaveNativePictureFormat:
=False,SaveFormsData:
=False,SaveAsAOCELetter:
False
打印出来
ActiveDocument.PrintOutFileName:
=doc,Range:
=wdPrintAllDocument,Item:
wdPrintDocumentContent,Copies:
=1,Pages:
PageType:
=wdPrintAllPages,_
ManualDuplexPrint:
=False,Collate:
=True,Background:
=True,PrintToFile:
False,PrintZoomColumn:
=0,PrintZoomRow:
=0,PrintZoomPaperWidth:
=0,_
PrintZoomPaperHeight:
=0
WORD中打字
Selection.TypeTextText:
您好,先生"
如何让Word的保存命令调用我自己编写的保存方法?
在doc文档被修改以后,在退出的时候当提示用户文档已经修改,问是否保存
和直接点击保存按钮的时候,能否让Word去调用我自己编写的SaveDoc方法,
如何实现?
创建名为“FileSave”的宏,把你的代码写入在这个宏中。
当点击“保存”按钮或退出程序要求“保存”时,都会直接执行你的“FileSave”宏,而不再执行Word的内置命令。
怎么样判断Word文档中有没有图片?
Word里的图片包括两种(据我所知),楼上的漏掉了InlineShapes
IfActiveDocument.Shapes.Count+ActiveDocument.InlineShapes.Count>
0Then
MsgBox"
esit"
Else
Documentdoesn'
tcontainashape"
QQ:
怎样在程序中把图片写入到word中。
AA:
功能是:
在指定位置插入图片并设置图片的格式(包括设置为衬托于文字下 方)
Sub设置图片格式()
Selection.InlineShapes.AddPictureFileName:
D:
\Mypicture\800x600.jpg"
_
LinkToFile:
=False,SaveWithDocument:
=True
Selection.MoveLeftUnit:
=wdCharacter,Count:
=1,Extend:
=wdExtend
Selection.InlineShapes
(1).ConvertToShape.Select
Selection.ShapeRange.Fill.Visible=msoFalse
Selection.ShapeRange.Fill.Transparency=0#
Selection.ShapeRange.Line.Weight=0.75
Selection.ShapeRange.Line.DashStyle=msoLineSolid
Selection.ShapeRange.Line.Style=msoLineSingle
Selection.ShapeRange.Line.Transparency=0#
Selection.ShapeRange.Line.Visible=msoFalse
Selection.ShapeRange.LockAspectRatio=msoTrue
Selection.ShapeRange.Height=361.4
Selection.ShapeRange.Width=481.6
Selection.ShapeRange.PictureFormat.Brightness=0.5
Selection.ShapeRange.PictureFormat.Contrast=0.5
Selection.ShapeRange.PictureFormat.ColorType=msoPictureAutomatic
Selection.ShapeRange.PictureFormat.CropLeft=0#
Selection.ShapeRange.PictureFormat.CropRight=0#
Selection.ShapeRange.PictureFormat.CropTop=0#
Selection.ShapeRange.PictureFormat.CropBottom=0#
Selection.ShapeRange.RelativeHorizontalPosition=_
wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition=_
wdRelativeVerticalPositionPage
Selection.ShapeRange.Left=wdShapeCenter
Selection.ShapeRange.Top=wdShapeCenter
Selection.ShapeRange.LockAnchor=False
Selection.ShapeRange.WrapFormat.AllowOverlap=True
Selection.ShapeRange.WrapFormat.Side=wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop=CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom=CentimetersToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft=CentimetersToPoints(0.32)
Selection.ShapeRange.WrapFormat.DistanceRight=CentimetersToPoints(0.32)
Selection.ShapeRange.WrapFormat.Type=3
‘实际上真正有用的是下面的语句设置图片为衬托于文字下方
Selection.ShapeRange.ZOrdermsoSendBehindText
EndSub
有没有方法,把一个word文件,按编号返回一段一段的段落文章。
比如
1XXXX
1.1YYYY
1.1.1ZZZZ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
1.1.2SSSS
PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
能够返回一个编号对应的一个标题和一段话。
谢谢
加载MicrosoftWord9.0ObjectLibrary
DimdcAppAsWord.Application
DimdcWdAsWord.Document
PrivateSubForm_Load()
SetdcApp=NewWord.Application
SetdcWd=dcApp.Documents.Open("
\rpt.doc"
)
Fori=1TodcWd.Paragraphs.Count
Debug.PrintdcWd.Paragraphs(i).Range.Text
Next
dcWd.Close
SetdcWd=Nothing
dcApp.Quit
SetdcApp=Nothing
如何用vb实现在word的bookmark后插入字符
在word模版中指定了boolmark:
a,
DimwrdappAsWord.Application
DimwrddocAsWord.Document
DimstrFileNameAsString
DimiAsVariant
dimsasstring
s="
要插入的字符"
Setwrdapp=CreateObject("
strFileName=App.Path&
"
Setwrddoc=wrdapp.Documents.Open(strFileName)
i=wrddoc.Range.GoTo(wdGoToBookmark,,,"
a"
后面该如何写,才能将s插入到bookmark后面?
另外我上面的代码正确吗?
VBA:
在word文档中搜索单词“审稿人”,将光标移到它后面,插入图片?
怎么实现!
!
我现在可以打开文件和插入图片了,就是没有搜索单词、移动光标、插入指定大小的图片的功能,那位老大出来指点指点呀?
我的代码如下:
OptionExplicit
DimDocAsNewDocument
DimVisiAsBoolean
DimwordAppAsWord.Application
DimdocWordAsWord.Document
PrivateSubCommand2_Click()
SetwordApp=NewWord.Application
SetdocWord=Word.Documents.Open("
\test.doc"
ActiveDocument.Shapes.AddPicture("
d:
\shan.jpg"
docWord.Save
docWord.Close
wordApp.Application.Quit()
wordApp.Find.ClearFormatting
wordApp.Find.Text="
审稿人"
wordApp.Find.Replacement.Text="
wordApp.Find.Forward=True
wordApp.Find.Wrap=wdFindContinue
wordApp.Find.Format=False
wordApp.Find.MatchCase=False
wordApp.Find.MatchWholeWord=False
wordApp.Find.MatchByte=True
wordApp.Find.CorrectHangulEndings=False
wordApp.Find.MatchAllWordForms=False
wordApp.Find.MatchSoundsLike=False
wordApp.Find.MatchWildcards=False
wordApp.Find.MatchFuzzy=False
wordApp.Find.Execute
请问如何将加载的菜单不是以悬浮的菜单形式出现?
CommandBar的Position属
在vb中将word文件保存为纯文本
PrivateSubCommand1_Click()
DimoWAsObject,oDAsObject,xAsObject
SetoW=CreateObject("
word.application"
SetoD=oW.documents.open("
\aaa.doc"
oW.Visible=True
ForEachxInoD.words
Text1=Text1&
x
Nextx
Open"
\bbb.txt"
ForOutputAs#1
Print#1,Text1
Close#1
oW.quit
怎么在一个word文档的最后插入东西
WORDXP的VB帮助中有示例:
本示例在名为“Changes.doc”的文档末尾插入文本。
“ForEach...Next”语句用来判断此文档是否已打开。
ForEachaDocumentInDocuments
IfInStr(LCase$(aDocument.Name),"
changes.doc"
)Then
SetmyRange=Documents("
Changes.doc"
).Content
myRange.InsertAfter"
theend."
NextaDocument
在WORD的宏里如何编写查询页数和行数,
ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
ActiveDocument.BuiltInDocumentProperties(wdPropertyLines)
请问网页考到word后,那个向下的箭头是什么标记,如何自动替换掉?
手工替换很麻烦阿!
但又不知道这是什么标记,无法下手阿。
急用!
手工换行符
可以用查找替换的,或者试试这个
Subblankdel()
DimiAsInteger
Fori=ActiveDocument.Paragraphs.CountTo1Step-1
ActiveDocument.Paragraphs(i).Range.Select
a=Selection.Words.Count
Ifa=1Then
Selection.Delete
m=m+1
Nexti
共删除空白段落"
&
m&
个"
按ALT+F11,把代码COPY进去运行一下就行了
请问怎么样用word对象中控制word的分页?
我刚刚试出来的:
此VB6下的代码可以解你问题
Setpword=CreateObject("
pword.Documents.AdddotName,False
pword.WindowState=2'
wdWindowStateMinimize'
2
pword.Selection.InsertBreakwdPageBreak
我想控制用户只能修改Word文件的部分内容,所以需要设置部分区域为只读,不知道该用什么方法,请大家赐教。
Selection.InsertBreakType:
=wdSectionBreakContinuous
ActiveDocument.Sections
(1).ProtectedForForms=False
ActiveDocument.Sections
(2).ProtectedForForms=True
ActiveDocument.ProtectPassword:
NoReset:
=False,Type:
wdAllowOnlyFormFields
请问怎么插入图片的
DimmyShapeAsShape
DimMyInshapeAsInlineShape
插入一个嵌入式图片对象
SetMyInshape=Selection.InlineShapes.AddPicture(FileName:
\pic001.jpg"
=True)
将InlineShape对象转变为Shape对象
SetmyShape=MyInshape.ConvertToShape
使图片浮于文字上方
myShape.WrapFormat.Type=wdWrapNone
如何访问表格单元格内容
objWordDoc.Tables(3).Cell(1,1).Range.Text
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VB 代码 word
![提示](https://static.bingdoc.com/images/bang_tan.gif)