Results 1 to 7 of 7

Thread: Embed ms project in a table in ms word

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Try this

    Code:
    Sub AddWordObject()
    
        Dim objDoc As Document
        Dim objTable As Table
        Dim strPath As String
        Dim objInlShp As InlineShape
        Const lngRows As Long = 2
        Const lngCols As Long = 3
        Const lngRowToAddObject As Long = 2
        Const lngColToAddObject As Long = 1
        Const strClassType As String = "MSProject.Project"
        strPath = "C:\\NewProjectWork.mpp"
        Set objDoc = ActiveDocument
        Set objTable = objDoc.Tables.Add(Range:=objDoc.Range, NumRows:=2, NumColumns:= _
            3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
            wdAutoFitFixed)
        With objTable
            If .Style <> "Table Grid" Then
                .Style = "Table Grid"
            End If
            .ApplyStyleHeadingRows = True
            .ApplyStyleLastRow = False
            .ApplyStyleFirstColumn = True
            .ApplyStyleLastColumn = False
            .ApplyStyleRowBands = True
            .ApplyStyleColumnBands = False
            .Range.Cells(lngCols * (lngRowToAddObject - 1) + 1).Row.Cells.Merge
            Set objInlShp = .Cell(lngRowToAddObject, lngColToAddObject).Range.InlineShapes.AddOLEObject(ClassType:=strClassType, FileName:=strPath, LinkToFile:=False, DisplayAsIcon:=True, Range:=.Cell(lngRowToAddObject, lngColToAddObject).Range)
            objInlShp.Width = .Cell(2, 1).Width
        End With
            
    End Sub


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 06-12-2023 at 01:03 PM.
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Replies: 7
    Last Post: 08-24-2015, 10:58 PM
  2. Excluding Records of one Table from the Other Table
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 05-17-2013, 12:32 AM
  3. Replies: 1
    Last Post: 10-16-2012, 01:53 PM
  4. Saving Embedded Picture From Excel Workbook Sheet To Folder Hard Drive
    By littleiitin in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 10-31-2011, 02:31 PM
  5. Project Planner
    By littleiitin in forum Download Center
    Replies: 0
    Last Post: 09-03-2011, 07:46 PM

Tags for this Thread

Posting Permissions

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