View Single Post
 
Old 08-11-2019, 09:24 PM
SamDsouza SamDsouza is offline Windows 10 Office 2013
Advanced Beginner
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

Hello

I tried as per your guidance but what happens when

Quote:
Set objDoc = Documents.Add(Template:="C:\WordTrial\cmdBtnWord.d ocm")
Quote:
This will create a new document that is an unnamed facsimile of the original. Or as it is a macro enabled document, you can simply open it as in your subsequent attempt.
It opens totally a new blank file. Where as i wanted the content to display on Page 2 because on Page 1 already command button is there to click and get the content on Page 2 of the .docm file

i tried the above without the below comments in Marked RED but added with syntax marked in Blue
Code:
Dim txtword As String
Dim objDoc As Document
Dim objRange As Range
Dim objTable As Table
Dim intRows As Integer
Dim intCols As Integer
    txtword = "fsdhfkhfkdhfdskfhd fkdshfdkfhdskfhdsfd fdshgfdjdsjfg" & vbCr
    Set objDoc = Documents.Add(Template:="C:\WordTrial\cmdBtnWord.docm")
With objDoc
             .Range.Text = txtword
             .Range.Font.Name = "Tahoma"
             .Range.Font.Size = "12"
             .Paragraphs.SpaceAfter = 0 
        End With 

    Set objRange = objDoc.Range
    objRange.Collapse Direction:=wdCollapseStart
    objRange.Text = txtword
    
   objRange.Collapse Direction:=wdCollapseEnd
    intRows = 8: intCols = 5
    Set objTable = objDoc.Tables.Add(objRange, intRows, intCols)
    objTable.Borders.Enable = True
Then i tried with red marked syntaxes and completely without Blue Marked Syntaxes then i got the error Method or Data member not found at the following line
Quote:
objRange.Range.Text = txtword
Reply With Quote