I use the following code to fetch the page for "cusp" from www.merriam-webstercom. It worked fine except that phonetic symbols didn't show up properly. I got things like these: \ˈkÉ™-ËŒspÄt, -spÉ™t . When trying to paste the phonetic symbols to this page, I got exactly the same scribbling things.
I searched the web but didn't get any helpful leads.
Any thoughts? Thanks.
Sub import_from_web(ByVal lookup_word As String)
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://www.merriam-webster.com/dictionary/" & lookup_word, Destination:= _
Range("$A$1"))
.Name = "d"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.TextFilePlatform = xlMSDOS
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
I ended up using a completely different approach. Instead of creating a link, I just opened the page and copied & pasted the page to Excel.
Thank to this thread:
Excel2010: PasteSpecial failing when copying from IE
Sub search_paste(ByRef IE As Object, ByVal lookup_word As String)
' this sub can handle non-ASCII characters
' it accepts a word from the calling sub and searches the word at Merian-Webster
' it then copies the web page and pastes to the ActiveSheet for further processing
With IE
.Visible = True
' .Navigate
.Navigate "https://www.merriam-webster.com/dictionary/" & lookup_word ' open the page containing the search word
Do Until .ReadyState = 4: DoEvents: Loop
End With
DoEvents
IE.ExecWB 17, 0 '// SelectAll
IE.ExecWB 12, 2 '// Copy selection
ActiveSheet.PasteSpecial link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
End Sub