Results 1 to 18 of 18

handle file between Word & Excel in VBA

Threaded View

  1. #1
    Registered User
    Join Date
    01-11-2017
    Location
    London, England
    MS-Off Ver
    2003,2007,2010,2013
    Posts
    65

    handle file between Word & Excel in VBA

    Hi all,

    well i have many files to handle between Word and Excel with a specific structure

    i want to copy all Green segments then generate an Excel file in same path and copy it to column (A)
    then copy all Yellow segments to same file but at column (B)



    after that when i finish some modifications at excel i want to copy them back to word file with same structure:
    Column (A) --> goes to Green
    Column (B) --> goes to Yellow


    Note: There are hidden segments i used wildcard "(\@)(*)(\^13)" to make them hidden


    sample file is attached too


    i tried my luck starting with this code, to export highlight text to a new excel file but i faced two problems


    first one it exports the text in column (B) but under other text in column (A) not opposite to it

    second issue that it exports text as sentences and divide it to two lines not as paragraphs

    and i'm still don't know how to get it back from excel to word with keeping same structure !!




    Sub ExportHighlightText()


    Dim docCur As Document
    Dim snt As Range
    Dim Paragraphs As Range
    Dim i As Integer

    Dim appXL As excel.Application, xlWB As excel.Workbook, xlWS As excel.Worksheet
    Dim path As XPath



    Set appXL = CreateObject("Excel.Application")
    appXL.Visible = True
    Set xlWB = appXL.Workbooks.Add
    Set xlWS = xlWB.Worksheets(1)




    Application.ScreenUpdating = False

    Set docCur = ActiveDocument


    For Each snt In docCur.Sentences
    If snt.HighlightColorIndex = wdBrightGreen Then
    i = i + 1
    xlWS.Cells(i, 1).Value = snt.Text
    End If
    Next snt


    For Each snt In docCur.Sentences
    If snt.HighlightColorIndex = wdYellow Then
    i = i + 1
    xlWS.Cells(i, 2).Value = snt.Text
    End If
    Next snt


    ExitHandler:
    Application.ScreenUpdating = True
    Set snt = Nothing
    Exit Sub



    Resume ExitHandler
    End Sub



    is it possible to do that in VBA, Any hint or help would be appreciated.


    Thanks in Advance

    Cheers

    Ethen




    Link posting: http://www.vbaexpress.com/forum/show...p-Excel-in-VBA
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Word 2016 is default, but hyperlinks in Excel file open Word 2010
    By 6StringJazzer in forum Excel General
    Replies: 2
    Last Post: 11-29-2016, 11:29 PM
  2. [SOLVED] How do I best handle these file messages?
    By terrypin in forum Excel General
    Replies: 2
    Last Post: 09-25-2016, 05:50 PM
  3. set word file format in excel and auto adjust requirement in file
    By adeel1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2016, 09:14 AM
  4. [SOLVED] How to read Excel or Word file (Multi-Word phrases) into Array
    By pradeepdeepu_001 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-15-2013, 03:02 AM
  5. Hiding table's handle in Word 2007
    By florence in forum Word Formatting & General
    Replies: 6
    Last Post: 09-11-2010, 04:43 PM
  6. Can a single excel file handle over 100,000 lines?
    By seigi009 in forum Excel General
    Replies: 2
    Last Post: 07-26-2007, 02:02 PM
  7. [SOLVED] overflow-how big a file can Excel handle?
    By John Smith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-04-2005, 06:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1