[ad_1]
To repeat, I want to copy a word from Word, paste it into the input field in the online dictionary, have the site return a result (OUTPUT), copy the output, and paste it back into Word on the next line after the word that was looked up. The word to look up is in the language "Gurmukhi" but this is irrelevant. The website (online dictionary) is here: https://www.srigranth.org/servlet/gurbani.dictionary To test how it works, you can click the words in the left margin here (although one would normally type or paste the word into the input field at the above site): https://www.sikhiwiki.org/index.php/Gurmukhi_to_English There are two possible outputs depending on whether the word being looked up IS FOUND or NOT FOUND. 1) First Possibility: the word IS FOUND START of OUTPUT string: The FOUND output string always STARTS with ANY ONE of 4 heading strings. These are: 4 Heading Strings 1) "SGGS Gurmukhi/Hindi to Punjabi-English/Hindi Dictionary" 2) "SGGS Gurmukhi-English Dictionary" 3) "English Translation" 4) "Mahan Kosh Encyclopedia" The first 15 characters of each are as follows: 1) "SGGS Gurmukhi/H" 2) "SGGS Gurmukhi-E" 3) "English Transla" 4) "Mahan Kosh Ency" END of OUTPUT string: the FOUND output string always ENDS just before the following string at the bottom of the page: "Mahan Kosh data provided by Bhai Baljinder Singh (RaraSahib Wale); See https://www.ik13.com" To summarize: When the word IS FOUND, the START and END of the OUTPUT string are as follows: START: the first character of the first instance of ANY ONE of the above 4 heading strings END: The character before the string (given above in full): "Mahan Kosh data provided by…" 2) Second Possibility: the word is NOT FOUND This is an example of the output string when the word is not found: "No search results found for ਅਵਗ. Please try another search." To summarize: When the word IS FOUND, the START and END of the OUTPUT string are as follows: START: The string: "No search results found for" END: the string "search." So essentially, the string between and including "No" and "search.". (note the middle part of the output string includes the word that was looked up)
私が試したこと:
VB
<pre>Sub Dictionary() 'Here is the code I have written. 'The first and last part that deal with Word are fine. 'I need help on the demarcated middle part where it says: ' "THIS IS THE PART I NEED HELP ON" Dim CopyRange As Range Dim PasteRange As Range Dim LookUpWord As String Set CopyRange = ActiveDocument.Paragraphs(1).Range LookUpWord = CopyRange.Text CopyRange.InsertParagraphAfter Set PasteRange = ActiveDocument.Paragraphs(2).Range Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") ie.Visible = True ie.navigate "https://www.srigranth.org/servlet/gurbani.dictionary" Do While ie.Busy Or ie.readyState <> 4 DoEvents Loop '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'THIS IS THE PART I NEED HELP ON 'Paste the word (variable: LookUpWord) into the input field 'at the website 'get the result/output from the site '(see explanation for what constitutes the OUTPUT) 'copy the result '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim OutputDefinition As String OutputDefinition = {contents of clipboard] PasteRange = OutputDefinition End Sub
解決策 1
これらのいずれかがあなたを助けるはずです
https://stackoverflow.com/questions/37733233/vba-macro-to-interact-with-specific-website[^]
VBA を使用して Internet Explorer (IE) を自動化する – Excel を自動化する[^]
あなたがその媒体を好むなら、いくつかのYouTubeビデオもあります – すべてこれで利用可能です この Google 検索[^] 「vba は Web サイトと対話します」
[ad_2]
コメント