Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 12-10-2023, 09:54 AM
RobiNew RobiNew is offline Separate strings in a text file Windows 10 Separate strings in a text file Office 2016
Competent Performer
Separate strings in a text file
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

Thanks a lot, Vivka, for the slight changes. It's all OK now.
Reply With Quote
  #17  
Old 12-12-2023, 10:07 AM
RobiNew RobiNew is offline Separate strings in a text file Windows 10 Separate strings in a text file Office 2016
Competent Performer
Separate strings in a text file
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

Hi, Vivka! I'm using your code, but I need your help once more. As you can see below, I added a few lines to your code, but I cannot achieve my aim, which is to insert the string |Chr(34) & ">"| after inserting text from a file.
Code:
Sub Test()
Dim oRng As range
Dim oRngD As range
Dim oRngDD As range
Dim vWd As Variant
Dim vHi As Variant
    Set oRng = ActiveDocument.range
    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "\<img width*\>"
        .Replacement.text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = True
        If .Execute Then
            Set oRngD = oRng.Duplicate
            Set oRngDD = oRng.Duplicate
            .text = "width=" & "[0-9]@ "
            .MatchWildcards = True
             If .Execute Then vWd = oRng
            With oRngD.Find
                .text = "height=" & "[0-9]@ "
                .MatchWildcards = True
                If .Execute Then  vHi = oRng
            End With
        End If
    End With
    oRngDD.Delete
'MsgBox "'" & vWd & "'" & vbCr & "'" & vHi & "'"
oRngDD.InsertAfter "<img " & vWd & vHi & "img src=" & Chr(34) & "data:image/jpg;base64,"
oRngDD.Collapse wdCollapseEnd
oRngDD.Select
oRngDD.InsertFile FileName:="C:\E_DIME.txt", Range:="", ConfirmConversions:= _
        False, link:=False, Attachment:=False
'Here I need to insert the string |Chr(34) & ">"| at the end of the text received from the file.
'Can you help? Thanks!
'???Range???.InsertAfter Chr(34) & ">"
lbl_Exit:
Set oRng = Nothing
Set oRngD = Nothing
Set oRngDD = Nothing
 End Sub
Reply With Quote
  #18  
Old 12-12-2023, 01:28 PM
vivka vivka is offline Separate strings in a text file Windows 7 64bit Separate strings in a text file Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Hi, RobiNew! Try this (perhaps, not the best method, but it works):
Code:
Sub Test()
Dim oRng As range
Dim oRngD As range
Dim oRngDD As range
Dim vWd As Variant
Dim vHi As Variant
    Set oRng = ActiveDocument.range
    With oRng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "\<img width*\>"
        .Replacement.text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchWildcards = True
        If .Execute Then
            Set oRngD = oRng.Duplicate
            Set oRngDD = oRng.Duplicate
            .text = "width=" & "[0-9]@ "
            .MatchWildcards = True
             If .Execute Then vWd = oRng
            With oRngD.Find
                .text = "height=" & "[0-9]@ "
                .MatchWildcards = True
                If .Execute Then vHi = oRngD
            End With
        End If
    End With
    oRngDD = "<img " & vWd & vHi & "img src=" & Chr(34) & "data:image/jpg;base64,"
    oRngDD.Collapse wdCollapseEnd
    oRngDD.InsertAfter Chr(34) & ">"
    oRngDD.Collapse
    oRngDD.InsertFile filename:="C:\E_DIME.txt", range:="", ConfirmConversions:= _
        False, Link:=False, Attachment:=False
lbl_Exit:
Set oRng = Nothing
Set oRngD = Nothing
Set oRngDD = Nothing
End Sub
Reply With Quote
  #19  
Old 12-12-2023, 03:40 PM
RobiNew RobiNew is offline Separate strings in a text file Windows 10 Separate strings in a text file Office 2016
Competent Performer
Separate strings in a text file
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default

Hi, Vivka! It does work! And for me it is perfect. Thank you very much indeed!
Reply With Quote
  #20  
Old 12-13-2023, 05:03 AM
vivka vivka is offline Separate strings in a text file Windows 7 64bit Separate strings in a text file Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

You are welcome, RobiNew!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to hide/delete slides based on keyword in a separate text file based on AND|OR condition? rupd911 PowerPoint 0 02-22-2021 08:22 AM
Separate strings in a text file Auto Save Every Page(s) as a separate file, and name each new file automatically by the first line? commissarmo Word VBA 3 03-14-2015 12:53 AM
Separate strings in a text file Copying a part of a docx file as a separate file officeboy09 Word 6 09-26-2014 05:15 PM
Separate strings in a text file Search Multiple strings and create new word file subodhgupta Word 4 05-22-2014 03:34 AM
Separate strings in a text file update style of all strings available between two specific strings vikrantkale Word 1 03-28-2011 06:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft