Word、Excel之宏应用问答.docx_第1页
Word、Excel之宏应用问答.docx_第2页
Word、Excel之宏应用问答.docx_第3页
Word、Excel之宏应用问答.docx_第4页
Word、Excel之宏应用问答.docx_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

QQ:有没有办法得到一个excle表的行的总数和列的总数?AA:xlSheet.UsedRange.Rows.CountxlSheet.UsedRange.Cols.CountQQ:如何打开一个word的模板!最近做一个word的模板程序,打开word是Set NewDoc = MyWord.Documents.Add这是一个新的doc,名字叫文档1(后面会累加,自动的),但是现在我希望直接新建打开一个我写好的模板程序,名字还是叫文档1。请问应该怎么写!AA:On Error Resume Next 忽略错误Set Wrd = GetObject(, Word.Application) 查找一个正在运行的Word拷贝If Err.Number 0 Then 如果 Word 没有运行则Set Wrd = CreateObject(Word.Application) 运行它End IfErr.Clear 清除发生错误的 Err 对象On Error GoTo 0 保留普通错误进程Dim dot As StringDim doc As StringWrd.Visible =truedot = C:temp.dotdoc = c:temp.docDocuments.Open FileName:=dot, _ConfirmConversions:=False, ReadOnly:=True, AddToRecentFiles:=False, _PasswordDocument:=, PasswordTemplate:=, Revert:=False, _WritePasswordDocument:=, WritePasswordTemplate:=, Format:= _0Wrd.ActiveDocument.CloseWrd.Documents.Add Template:=dot, NewTemplate:=False结果系列操作ActiveDocument.SaveAs FileName:=doc, FileFormat:=wdFormatDocument, _LockComments:=False, Password:=, AddToRecentFiles:=True, WritePassword _:=, ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _False打印出来ActiveDocument.PrintOut FileName:=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:=0Wrd.ActiveDocument.CloseWORD中打字Selection.TypeText Text:=您好,先生如何让Word的保存命令调用我自己编写的保存方法?在doc文档被修改以后,在退出的时候当提示用户文档已经修改,问是否保存和直接点击保存按钮的时候,能否让Word去调用我自己编写的SaveDoc方法,如何实现?创建名为“FileSave”的宏,把你的代码写入在这个宏中。当点击“保存”按钮或退出程序要求“保存”时,都会直接执行你的“FileSave”宏,而不再执行Word的内置命令。怎么样判断Word文档中有没有图片?Word里的图片包括两种(据我所知),楼上的漏掉了InlineShapesIf ActiveDocument.Shapes.Count + ActiveDocument.InlineShapes.Count 0 ThenMsgBox esitElseMsgBox Document doesnt contain a shapeEnd IfQQ:怎样在程序中把图片写入到中。AA:功能是:在指定位置插入图片并设置图片的格式(包括设置为衬托于文字下方)Sub 设置图片格式()Selection.InlineShapes.AddPicture FileName:=D:Mypicture800x600.jpg, _LinkToFile:=False, SaveWithDocument:=TrueSelection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtendSelection.InlineShapes(1).ConvertToShape.SelectSelection.ShapeRange.Fill.Visible = msoFalseSelection.ShapeRange.Fill.Transparency = 0#Selection.ShapeRange.Line.Weight = 0.75Selection.ShapeRange.Line.DashStyle = msoLineSolidSelection.ShapeRange.Line.Style = msoLineSingleSelection.ShapeRange.Line.Transparency = 0#Selection.ShapeRange.Line.Visible = msoFalseSelection.ShapeRange.LockAspectRatio = msoTrueSelection.ShapeRange.Height = 361.4Selection.ShapeRange.Width = 481.6Selection.ShapeRange.PictureFormat.Brightness = 0.5Selection.ShapeRange.PictureFormat.Contrast = 0.5Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomaticSelection.ShapeRange.PictureFormat.CropLeft = 0#Selection.ShapeRange.PictureFormat.CropRight = 0#Selection.ShapeRange.PictureFormat.CropTop = 0#Selection.ShapeRange.PictureFormat.CropBottom = 0#Selection.ShapeRange.RelativeHorizontalPosition = _wdRelativeHorizontalPositionColumnSelection.ShapeRange.RelativeVerticalPosition = _wdRelativeVerticalPositionPageSelection.ShapeRange.Left = wdShapeCenterSelection.ShapeRange.Top = wdShapeCenterSelection.ShapeRange.LockAnchor = FalseSelection.ShapeRange.WrapFormat.AllowOverlap = TrueSelection.ShapeRange.WrapFormat.Side = wdWrapBothSelection.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.ZOrder msoSendBehindTextEnd SubQQ:有没有方法,把一个word文件,按编号返回一段一段的段落文章。比如1 XXXX1.1 YYYY1.1.1 ZZZZQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ1.1.2 SSSSPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP能够返回 一个编号对应的一个标题和一段话。谢谢AA:加载Microsoft Word 9.0 Object LibraryDim dcApp As Word.ApplicationDim dcWd As Word.DocumentPrivate Sub Form_Load()Set dcApp = New Word.ApplicationSet dcWd = dcApp.Documents.Open(c:rpt.doc)For i = 1 To dcWd.Paragraphs.CountDebug.Print dcWd.Paragraphs(i).Range.TextNextdcWd.CloseSet dcWd = NothingdcApp.QuitSet dcApp = NothingEnd SubQQ:如何用vb实现在word的bookmark后插入字符在word模版中指定了boolmark:a,Dim wrdapp As Word.ApplicationDim wrddoc As Word.DocumentDim strFileName As StringDim i As Variantdim s as strings=要插入的字符Set wrdapp = CreateObject(Word.Application)strFileName = App.Path & temp.dotSet wrddoc = wrdapp.Documents.Open(strFileName)i = wrddoc.Range.GoTo(wdGoToBookmark, , , a)后面该如何写,才能将s插入到bookmark后面?另外我上面的代码正确吗?谢谢?QQ: VBA:在word文档中搜索单词“审稿人”,将光标移到它后面,插入图片?怎么实现!我现在可以打开文件和插入图片了,就是没有搜索单词、移动光标、插入指定大小的图片的功能,那位老大出来指点指点呀?我的代码如下:Option ExplicitDim Doc As New DocumentDim Visi As BooleanDim wordApp As Word.ApplicationDim docWord As Word.DocumentPrivate Sub Command2_Click()Set wordApp = New Word.ApplicationSet docWord = Word.Documents.Open(D:test.doc)ActiveDocument.Shapes.AddPicture (d:shan.jpg)docWord.SavedocWord.ClosewordApp.Application.Quit()End SubAA:wordApp.Find.ClearFormattingwordApp.Find.Text = 审稿人wordApp.Find.Replacement.Text = wordApp.Find.Forward = TruewordApp.Find.Wrap = wdFindContinuewordApp.Find.Format = FalsewordApp.Find.MatchCase = FalsewordApp.Find.MatchWholeWord = FalsewordApp.Find.MatchByte = TruewordApp.Find.CorrectHangulEndings = FalsewordApp.Find.MatchAllWordForms = FalsewordApp.Find.MatchSoundsLike = FalsewordApp.Find.MatchWildcards = FalsewordApp.Find.MatchFuzzy = FalsewordApp.Find.ExecuteQQ:请问如何将加载的菜单不是以悬浮的菜单形式出现?AA:CommandBar的Position属QQ: 在vb 中将word文件保存为纯文本AA:Private Sub Command1_Click()Dim oW As Object, oD As Object, x As ObjectSet oW = CreateObject(word.application)Set oD = oW.documents.open(c:aaa.doc)oW.Visible = TrueFor Each x In oD.wordsText1 = Text1 & xNext xOpen c:bbb.txt For Output As #1Print #1, Text1Close #1oW.quitEnd SubQQ:怎么在一个word文档的最后插入东西AA:WORD XP的VB帮助中有示例:本示例在名为“Changes.doc”的文档末尾插入文本。“For Each.Next”语句用来判断此文档是否已打开。For Each aDocument In DocumentsIf InStr(LCase$(aDocument.Name), changes.doc) ThenSet myRange = Documents(Changes.doc).ContentmyRange.InsertAfter the end.End IfNext aDocumentQQ:在WORD的宏里如何编写查询页数和行数,AA:ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)ActiveDocument.BuiltInDocumentProperties(wdPropertyLines)QQ:请问网页考到word后,那个向下的箭头是什么标记,如何自动替换掉?手工替换很麻烦阿!但又不知道这是什么标记,无法下手阿。急用!AA:手工换行符可以用查找替换的,或者试试这个Sub blankdel()Dim i As IntegerFor i = ActiveDocument.Paragraphs.Count To 1 Step -1ActiveDocument.Paragraphs(i).Range.Selecta = Selection.Words.CountIf a = 1 ThenSelection.Deletem = m + 1End IfNext iMsgBox 共删除空白段落 & m & 个End Sub按ALT+F11,把代码COPY进去运行一下就行了QQ:请问怎么样用word对象中控制word的分页?AA:我刚刚试出来的:此VB6下的代码可以解你问题Set pword = CreateObject(Word.Application)pword.Documents.Add dot

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论