QQ:有没有办法得到一个excle表的行的总数和列的总数?? AA: xlSheet.UsedRange.Rows.Count xlSheet.UsedRange.Cols.Count QQ: 如何打开一个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 If Err.Clear ''清除发生错误的 Err 对象 On Error GoTo 0 ''保留普通错误进程 Dim dot As String Dim doc As String Wrd.Visible =true dot = "C:\temp.dot" doc = "c:\temp.doc" Documents.Open FileName:=dot, _ ConfirmConversions:=False, ReadOnly:=True, AddToRecentFiles:=False, _ PasswordDocument:="", PasswordTemplate:="", Revert:=False, _ WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _ 0 Wrd.ActiveDocument.Close Wrd.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:=0 Wrd.ActiveDocument.Close WORD中打字 Selection.TypeText Text:="您好,先生" 如何让Word的保存命令调用我自己编写的保存方法? 在doc文档被修改以后,在退出的时候当提示用户文档已经修改,问是否保存 和直接点击保存按钮的时候,能否让Word去调用我自己编写的SaveDoc方法, 如何实现? 创建名为“FileSave”的宏,把你的代码写入在这个宏中。当点击“保存”按钮或退出程序要求“保存”时,都会直接执行你的“FileSave”宏,而不再执行Word的内置命令。 怎么样判断Word文档中有没有图片? Word里的图片包括两种(据我所知),楼上的漏掉了InlineShapes If ActiveDocument.Shapes.Count + ActiveDocument.InlineShapes.Count > 0 Then MsgBox "esit" Else MsgBox "Document doesn''t contain a shape" End If QQ:怎样在程序中把图片写入到word中。 AA: 功能是:在指定位置插入图片并设置图片的格式(包括设置为衬托于文字下 方) Sub 设置图片格式() Selection.InlineShapes.AddPicture FileName:="D:\Mypicture\800x600.jpg", _ LinkToFile:=False, SaveWithDocument:=True Selection.MoveLeft Unit:=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.ZOrder msoSendBehindText End Sub QQ:有没有方法,把一个word文件,按编号返回一段一段的段落文章。 比如 1 XXXX 1.1 YYYY 1.1.1 ZZZZ QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ 1.1.2 SSSS PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP 能够返回 一个编号对应的一个标题和一段话。 谢谢 AA: 加载Microsoft Word 9.0 Object Library Dim dcApp As Word.Application Dim dcWd As Word.Document Private Sub Form_Load() Set dcApp = New Word.Application Set dcWd = dcApp.Documents.Open("c:\rpt.doc") For i = 1 To dcWd.Paragraphs.Count Debug.Print dcWd.Paragraphs(i).Range.Text Next dcWd.Close Set dcWd = Nothing dcApp.Quit Set dcApp = Nothing End Sub QQ:如何用vb实现在word的bookmark后插入字符 在word模版中指定了boolmark:a, Dim wrdapp As Word.Application Dim wrddoc As Word.Document Dim strFileName As String Dim i As Variant dim s as string s="要插入的字符" Set wrdapp = CreateObject("Word.Application") strFileName = App.Path & "\temp.dot" Set wrddoc = wrdapp.Documents.Open(strFileName) i = wrddoc.Range.GoTo(wdGoToBookmark, , , "a") 后面该如何写,才能将s插入到bookmark后面?另外我上面的代码正确吗?谢谢 ?????????????? QQ: VBA:在word文档中搜索单词“审稿人”,将光标移到它后面,插入图片?怎么实现!!! 我现在可以打开文件和插入图片了,就是没有搜索单词、移动光标、插入指定大小的图片的功能,那位老大出来指点指点呀? 我的代码如下: Option Explicit Dim Doc As New Document Dim Visi As Boolean Dim wordApp As Word.Application Dim docWord As Word.Document Private Sub Command2_Click() Set wordApp = New Word.Application Set docWord = Word.Documents.Open("D:\test.doc") ActiveDocument.Shapes.AddPicture ("d:\shan.jpg") docWord.Save docWord.Close wordApp.Application.Quit() End Sub AA: 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 QQ:请问如何将加载的菜单不是以悬浮的菜单形式出现? AA:CommandBar的Position属 QQ: 在vb 中将word文件保存为纯文本 AA: Private Sub Command1_Click() Dim oW As Object, oD As Object, x As Object Set oW = CreateObject("word.application") Set oD = oW.documents.open("c:\aaa.doc") ''oW.Visible = True For Each x In oD.words Text1 = Text1 & x Next x Open "c:\bbb.txt" For Output As #1 Print #1, Text1 Close #1 oW.quit End Sub QQ:怎么在一个word文档的最后插入东西 AA: WORD XP的VB帮助中有示例: 本示例在名为“Changes.doc”的文档末尾插入文本。“For Each...Next”语句用来判断此文档是否已打开。 For Each aDocument In Documents If InStr(LCase$(aDocument.Name), "changes.doc") Then Set myRange = Documents("Changes.doc").Content myRange.InsertAfter "the end." End If Next aDocument QQ:在WORD的宏里如何编写查询页数和行数, AA: ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) ActiveDocument.BuiltInDocumentProperties(wdPropertyLines) QQ:请问网页考到word后,那个向下的箭头是什么标记,如何自动替换掉?手工替换很麻烦阿!但又不知道这是什么标记,无法下手阿。急用!! AA: 手工换行符 可以用查找替换的,或者试试这个 Sub blankdel() Dim i As Integer For i = ActiveDocument.Paragraphs.Count To 1 Step -1 ActiveDocument.Paragraphs(i).Range.Select a = Selection.Words.Count If a = 1 Then Selection.Delete m = m + 1 End If Next i MsgBox "共删除空白段落" & m & "个" End Sub 按ALT+F11,把代码COPY进去运行一下就行了 QQ:请问怎么样用word对象中控制word的分页? AA: 我刚刚试出来的:此VB6下的代码可以解你问题 Set pword = CreateObject("Word.Application") pword.Documents.Add dotName, False pword.WindowState = 2 ''wdWindowStateMinimize ''2 pword.Selection.InsertBreak wdPageBreak QQ:我想控制用户只能修改Word文件的部分内容,所以需要设置部分区域为只读,不知道该用什么方法,请大家赐教。 AA: Selection.InsertBreak Type:=wdSectionBreakContinuous ActiveDocument.Sections(1).ProtectedForForms = False ActiveDocument.Sections(2).ProtectedForForms = True ActiveDocument.Protect Password:="", NoReset:=False, Type:= _ wdAllowOnlyFormFields QQ:请问怎么插入图片的 AA: Dim myShape As Shape Dim MyInshape As InlineShape ''插入一个嵌入式图片对象 Set MyInshape = Selection.InlineShapes.AddPicture(FileName:="D:\pic001.jpg", _ LinkToFile:=False, SaveWithDocument:=True) ''将InlineShape对象转变为Shape对象 Set myShape = MyInshape.ConvertToShape ''使图片浮于文字上方 myShape.WrapFormat.Type = wdWrapNone QQ:如何访问表格单元格内容 AA: objWordDoc.Tables(3).Cell(1, 1).Range.Text
|