![]() |
|
![]() |
|
Thread Tools | Display Modes |
#16
|
||||
|
||||
![]() You said that in your last post. What do you want it replaced with?
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#17
|
|||
|
|||
![]()
With data present in excel. The same excel which we used in earlier macro. The data present in one cell that is B45
|
#18
|
||||
|
||||
![]()
OK The following will do that, however it will not be formatted in the same manner with each line a separate paragraph indented with spaces. It will be formatted to look the same using a pargraph format with a half inch indent.
Code:
Option Explicit Sub ReplacePara() Dim lPara As Long Dim oRng As Range Dim oCC As ContentControl With ActiveDocument For lPara = .Paragraphs.Count To 1 Step -1 If InStr(1, .Paragraphs(lPara).Range.Text, _ "Nature and Necessity") > 0 Then Set oRng = .Paragraphs(lPara).Range oRng.MoveStart wdParagraph Exit For End If Next lPara For lPara = .Paragraphs.Count To 1 Step -1 If InStr(1, .Paragraphs(lPara).Range.Text, _ "*****THIS IS A COMPLETE UNDERTAKING*****") > 0 Then oRng.End = .Paragraphs(lPara).Range.End - 1 Exit For End If Next lPara oRng.Select oRng.ParagraphFormat.LeftIndent = InchesToPoints(0.5) oRng.Font.Bold = False oRng.Text = GetExcelB45Data End With End Sub Private Function GetExcelB45Data() As String Dim strWorkbook As String: strWorkbook = "C:\Path\Job Aid Bay.xlsm" 'The path of the workbook Dim xlApp As Object Dim xlBook As Object On Error Resume Next Set xlApp = GetObject(, "Excel.Application") If Err Then Set xlApp = CreateObject("Excel.Application") End If On Error GoTo 0 Set xlBook = xlApp.Workbooks.Open(FileName:=strWorkbook) xlApp.Visible = True GetExcelB45Data = xlBook.Sheets("MAIN").Range("B45") 'the Excel cell to copy xlBook.Close savechanges:=False lbl_Exit: Err.Clear Set xlBook = Nothing Set xlApp = Nothing Exit Function End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#19
|
|||
|
|||
![]()
Thanks sir...
Want to know one thing. In excel file on Main Sheet we have a dropdown list which has a multiple items when we select an item from list data on another get change now i want to copy that change data issue here is the data in another sheet is not always showing on fixed cell number. The cell number is changing on every select in dropdown. How to get this. |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
jp91306 | Word | 3 | 04-23-2019 03:32 PM |
I want to create a bar chart of multiple variable. Then I need to draw trend lin of those variable | shimulsiddiquee | Excel | 1 | 05-16-2017 07:39 AM |
Replacing paragraph formatting before column break also changes the next paragraph after the break | jjmartin1340 | Word | 3 | 09-21-2015 10:50 PM |
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge | Berryblue | Mail Merge | 1 | 11-13-2014 05:36 PM |