<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    飛艷小屋

    程序--人生--哲學___________________歡迎艷兒的加入

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      52 Posts :: 175 Stories :: 107 Comments :: 0 Trackbacks
    8月3日
    這些VBA代碼會有用
    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
    posted on 2005-12-06 15:51 天外飛仙 閱讀(4012) 評論(3)  編輯  收藏 所屬分類: .net

    Feedback

    # re: VB代碼word,excel 2006-12-06 18:08 hdp
    用vba如何把word 中的指定字符寫到到execl指定的單元格  回復  更多評論
      

    # 如何禁止插入到word中的圖片被拖動[未登錄] 2007-12-27 10:04 jack
    如何禁止插入到word中的圖片被拖動  回復  更多評論
      

    # re: VB代碼word,excel 2009-01-27 11:02 lwpc4203
    VB 寫入word以后如何實現換行呢?  回復  更多評論
      

    主站蜘蛛池模板: aⅴ免费在线观看| 无码人妻久久一区二区三区免费 | 亚洲av永久无码精品表情包| 亚洲AV成人精品一区二区三区| 国产卡一卡二卡三免费入口| 亚洲天堂福利视频| 亚洲网站在线免费观看| 亚洲国产精品张柏芝在线观看| 999久久久免费精品播放| 亚洲电影免费观看| 无码人妻精品中文字幕免费东京热| 亚洲视频在线观看不卡| 亚欧在线精品免费观看一区| 亚洲白色白色永久观看| AV片在线观看免费| 国产成人+综合亚洲+天堂| 亚洲av无码专区在线观看素人| 一区二区三区在线免费观看视频| 久久影院亚洲一区| 久久久99精品免费观看| 亚洲资源在线视频| 成人免费视频观看无遮挡| 真人无码作爱免费视频| 久久亚洲国产精品123区| 久久精品无码精品免费专区| 亚洲综合亚洲国产尤物| 国产一卡二卡3卡四卡免费| 亚洲av无码一区二区三区在线播放| 国产男女猛烈无遮挡免费视频网站| 男人免费视频一区二区在线观看| a级亚洲片精品久久久久久久| 久久免费看少妇高潮V片特黄| 精品亚洲AV无码一区二区三区| 日日操夜夜操免费视频| 99久久精品毛片免费播放| 亚洲最新黄色网址| 国产免费观看黄AV片| 野花香高清视频在线观看免费| 亚洲成aⅴ人片在线影院八| 亚洲国产人成中文幕一级二级| 十九岁在线观看免费完整版电影|