Consulting

Results 1 to 4 of 4

Thread: What is the error?

  1. #1
    VBAX Contributor
    Joined
    Nov 2009
    Posts
    114
    Location

    What is the error?

    This is the excel vba. What is the error. Thank you very much!

    [vba]
    Set wrdApp = CreateObject("Word.Application")
    Set wrdDoc = wrdApp.Documents.Open("C:\abc.doc")



    Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy
    wrdApp.Selection.GoTo What:=wdGoToBookmark, Name:="a"
    wrdApp.Selection.PasteExcelTable False, False, False


    'error
    Dim wkb As Excel.Workbook

    Set wkb = Thisworkbook
    'error

    wrdApp.Selection.GoTo What:=wdGoToBookmark, Name:="b"
    wrdApp.Selection.MoveRight Unit:=wdCharacter, Count:=10
    wrdApp.Selection.TypeBackspace
    wrdApp.Selection.TypeBackspace
    wrdApp.Selection.TypeBackspace
    wrdApp.Selection.TypeBackspace
    wrdApp.Selection.TypeBackspace
    wrdApp.Selection.TypeBackspace
    wrdApp.Selection.TypeBackspace
    wrdApp.Selection.TypeBackspace
    wrdApp.Selection.TypeBackspace
    wrdApp.Selection.TypeBackspace


    'error
    wrdApp.Selection.TypeText wkb.Worksheets("1").Cells(1, 1)
    'error


    Set wkb = Nothing




    wrdDoc.SaveAs "D:\abc.doc"


    wrdDoc.Close
    wrdApp.Quit
    Set wrdDoc = Nothing
    Set wrdApp = Nothing
    [/vba]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Wrong forum.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Nov 2009
    Posts
    114
    Location
    I do not know how to define the workbook. It is excel vba to control word file. Anyone can help!

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Review these to see what you need.

    'TypeText method
    ' http://www.excelforum.com/excel-prog...ml#post1946784
    ' http://www.excelforum.com/showthread.php?p=1946784
    ' http://vbaexpress.com/forum/showthread.php?p=169877
    ' http://vbaexpress.com/forum/showthread.php?t=24693

    'Copy from Excel, paste to Word
    'Lucas, http://vbaexpress.com/forum/showthread.php?p=178364

    'FormFields
    ' http://www.mrexcel.com/forum/showthread.php?p=1639696
    ' http://www.mrexcel.com/forum/showthread.php?t=333200

    'Add Hyperlink to Bookmark
    ' http://www.excelforum.com/excel-prog...ml#post2006430
    'Steiner, http://www.vbaexpress.com/kb/getarticle.php?kb_id=126
    'Colin_L, http://www.mrexcel.com/forum/showthread.php?t=358054

    'Save OLEObject as MSWord Document
    ' http://vbaexpress.com/forum/showthread.php?t=21619

    'Add Table to MSWord
    ' http://vbaexpress.com/forum/showthread.php?t=23975
    ' http://vbaexpress.com/forum/showthread.php?p=168731

    'Import Word Tables
    ' vog, http://www.mrexcel.com/forum/showthread.php?t=382541

    'Save OLEObject as MSWord DOC
    ' http://www.mrexcel.com/forum/showthread.php?p=2809902
    ' http://vbaexpress.com/forum/showthread.php?t=21619

    'Get Optionbutton info from MSWord DOC
    ' http://vbaexpress.com/forum/showthread.php?t=22454

    'FindReplace Text
    ' http://www.excelforum.com/excel-prog...-ms-excel.html
    ' Multiple Find/Replace
    ' http://www.excelforum.com/excel-prog...o-to-word.html
    ' Single Find/Replace
    ' http://www.vbaexpress.com/forum/showthread.php?t=38958

    'Bookmarks
    ' http://vbaexpress.com/forum/showthread.php?p=185718

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •