brkkrkmz112
New Member
- Joined
- Oct 24, 2016
- Messages
- 43
Hello,
I've done some searching but can't find anything works. I need to use path of hyperlinks but some of them contains box brackets and it is shown like %5b %5d etc. Hyperlinks are working perfectly but for the other macro I need to take path information from hyperlinks and the ones containes box brackets cause error which is path could not found.
Is there anything that I can do. I sharing the code below. Thank you.
I've done some searching but can't find anything works. I need to use path of hyperlinks but some of them contains box brackets and it is shown like %5b %5d etc. Hyperlinks are working perfectly but for the other macro I need to take path information from hyperlinks and the ones containes box brackets cause error which is path could not found.
Is there anything that I can do. I sharing the code below. Thank you.
VBA Code:
Sub burak()
Dim outapp As Object
Dim foldername As String
Dim Msg As Object
Dim foldername1 As String, foldername2 As String
Dim dosya As Object
Dim wordapp As Object
Dim worddoc As Object
Application.ScreenUpdating = False
Dim sNewDocName As String
Set wordapp = CreateObject("Word.Application")
Set outapp = CreateObject("Outlook.Application")
foldername1 = Selection.Hyperlinks(1).Address
foldername = ThisWorkbook.Path + "\" + foldername1
foldername2 = Right(foldername1, Len(foldername1) - 4)
foldername2 = Left(foldername2, Len(foldername2) - 4)
Set Msg = outapp.Session.OpenSharedItem(foldername)
Msg.Display
Msg.SaveAs "C:\Users\Administrator\Desktop\Mail1\REFPDF\" & foldername2 & ".doc", olDoc
Set worddoc = wordapp.Documents.Open(Filename:="C:\Users\Administrator\Desktop\Mail1\REFPDF\" & foldername2 & ".doc")
worddoc.ExportAsFixedFormat OutputFileName:= _
"C:\Users\Administrator\Desktop\Mail1\REFPDF\" & foldername2 & ".pdf", ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=0, To:=0, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
ActiveSheet.Hyperlinks.Add Range("r" & Selection.Row), "C:\Users\Administrator\Desktop\Mail1\REFPDF\" & foldername2 & ".pdf", TextToDisplay:="GAP's evaluation"
Msg.Close olDiscard
Application.ScreenUpdating = True
End Sub