<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Удаление лишнего пробела]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13690&amp;type=atom" />
	<updated>2018-05-10T08:45:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=13690</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Удаление лишнего пробела]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125271#p125271" />
			<content type="html"><![CDATA[<p><strong>stealzy</strong> Немного не туда вставил, вот так работает</p><div class="codebox"><pre><code>ie.document.getElementsByTagName(&quot;input&quot;)[2].value := Xl.Sheets(Sheet_To_Calculate).Range(&quot;F&quot; . Current_Row).Value
sleep 200
ie.document.getElementsByTagName(&quot;button&quot;)[0].click()
Sleep 2500
Xl.Range(&quot;B&quot; . Current_Row).Value := ie.document.getElementsByTagName(&quot;span&quot;)[1].innerText
sleep 300
str := ie.document.getElementsByTagName(&quot;span&quot;)[3].innerText
StringTrimRight, str, str, 1
Xl.Range(&quot;C&quot; . Current_Row).Value := str
sleep 300</code></pre></div><p>Еще раз спасибо. А можно еще вопрос. Возможно ли растянуть формулу до конца заполняемых строк. Пока только формула в А2 и H2</p><div class="codebox"><pre><code>Xl.Range(&quot;A2&quot;).Formula := &quot;=B2&amp;C2&quot; 
sleep 50
raf = =ЕСЛИ(СЧЁТЕСЛИ(A2:D2; D2)&gt;1; &quot;Дубликат&quot;; &quot;УНИК&quot;)
Xl.Range(&quot;H2&quot;).Formula := raf
sleep 50</code></pre></div>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2018-05-10T08:45:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125271#p125271</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Удаление лишнего пробела]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125223#p125223" />
			<content type="html"><![CDATA[<p><strong>stealzy</strong> а в экселе остается с пробелом.<br />Вот полный код<br /></p><div class="codebox"><pre><code>SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

$^1::
Setkeydelay, 35

Loginname = ***
Password = ****
ie := ComObjCreate(&quot;InternetExplorer.Application&quot;)
ie.Visible := true
ie.Navigate(&quot;****&quot;)
while ie.readystate &lt;&gt; 4
	continue
ie.document.getElementsByTagName(&quot;input&quot;)[0].value := Loginname
ie.document.getElementsByTagName(&quot;input&quot;)[1].value := Password
ie.document.getElementsByTagName(&quot;input&quot;)[2].click()
Sleep 2000
ie.document.getElementsByTagName(&quot;a&quot;)[0].click()


; Выбор экселевскгого файла дял проверки
FileSelectFile, Path, 3, , Open Excel File, Excel File (*.xls; *.xlsx)
if Path =
	ExitApp
Xl := ComObjCreate(&quot;Excel.Application&quot;)
Xl.Workbooks.Open(Path) ;open an existing file
Xl.Visible := True
if Errorlevel
{
	MsgBox, % &quot;Error opening excel file! Exiting...&quot;
	ExitApp
}

; Выбор листа в книге
Sheet_Titles =
global Sheet_To_Calculate := 0 
loop, % xl.Sheets.Count
	Sheet_Titles .= A_Index . &quot;: &quot; . xl.Sheets(A_Index).Name . &quot;`n&quot;
While Sheet_To_Calculate &lt; 1 || Sheet_To_Calculate &gt; xl.Sheets.Count || !IF_Integer(Sheet_To_Calculate)
	inputbox, Sheet_To_Calculate, % Xl.ActiveWorkbook.Name, %Sheet_Titles%, , , , , , , , 1
if ErrorLevel
	ExitApp


; Выбор строки, с которой начинать копирование
global Current_Row := -1
While Current_Row &lt; 1 || !IF_Integer(Current_Row)
	inputbox, Current_Row, % Xl.ActiveWorkbook.Name, % &quot;Enter the row to start on.&quot;, , , , , , , , 2
if ErrorLevel
	ExitApp

; THE REAL MEAT :) while the current row&#039;s A column is not blank, continue the loop
while Xl.Sheets(Sheet_To_Calculate).Range(&quot;F&quot; . Current_Row).Value != &quot;&quot;
{

  ; Выбор столбца с № документа
	
F_stored := Xl.Sheets(Sheet_To_Calculate).Range(&quot;F&quot; . Current_Row).Value
	

Sleep 200
ie.document.getElementsByTagName(&quot;input&quot;)[2].value := Xl.Sheets(Sheet_To_Calculate).Range(&quot;F&quot; . Current_Row).Value
sleep 200
ie.document.getElementsByTagName(&quot;button&quot;)[0].click()
Sleep 2500
Xl.Range(&quot;B&quot; . Current_Row).Value := ie.document.getElementsByTagName(&quot;span&quot;)[1].innerText
sleep 300
Xl.Range(&quot;C&quot; . Current_Row).Value := ie.document.getElementsByTagName(&quot;span&quot;)[3].innerText
sleep 300


; Move to the next row
	Current_Row++
}


Xl.Range(&quot;A2&quot;).Formula := &quot;=RC[1]&amp;RC[2]&quot; 
sleep 50

MsgBox, % &quot;Сделано!&quot;
sleep 100
path := xl.ActiveWorkbook.path
name := xl.ActiveWorkbook.name
Str := RegExReplace(name, &quot;.xlsx&quot;)
file := path &quot;\&quot; Str &quot;_проверено&quot; &quot;.xlsx&quot;
xl.ActiveWorkbook.SaveAs(file, 51)
sleep 100
Xl.ActiveWorkbook.close()
ie.quit
ExitApp



IF_Integer(check_this)
{
	if check_this is not integer
		return false
	else
		return true
}

return 

F12::                 
Pause
return



$Esc::ExitApp ;EMERGENCY EXIT HOTKEY</code></pre></div>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2018-05-08T14:52:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125223#p125223</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Удаление лишнего пробела]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125219#p125219" />
			<content type="html"><![CDATA[<p><strong>KusochekDobra</strong> Ошибок нет, но пробел не удаляется, скорее всего я косячу</p><div class="codebox"><pre><code>..............

while Xl.Sheets(Sheet_To_Calculate).Range(&quot;F&quot; . Current_Row).Value != &quot;&quot;
{

  ; Выбор столбца с № документа
	
F_stored := Xl.Sheets(Sheet_To_Calculate).Range(&quot;F&quot; . Current_Row).Value
	

Sleep 200
ie.document.getElementsByTagName(&quot;input&quot;)[2].value := Xl.Sheets(Sheet_To_Calculate).Range(&quot;F&quot; . Current_Row).Value
sleep 200
ie.document.getElementsByTagName(&quot;button&quot;)[0].click()
Sleep 2500
Xl.Range(&quot;B&quot; . Current_Row).Value := ie.document.getElementsByTagName(&quot;span&quot;)[1].innerText
sleep 300
Xl.Range(&quot;C&quot; . Current_Row).Value := ie.document.getElementsByTagName(&quot;span&quot;)[3].innerText
sleep 300
str := Xl.Range(&quot;C&quot; . Current_Row).Value
StringTrimRight, str, str, 1


; Move to the next row
	Current_Row++
}

Xl.Range(&quot;A2&quot;).Formula := &quot;=RC[1]&amp;RC[2]&quot; 
sleep 50


MsgBox, % &quot;Сделано!&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2018-05-08T13:17:10Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125219#p125219</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Удаление лишнего пробела]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125218#p125218" />
			<content type="html"><![CDATA[<p>Здравствуйте!<br />Используйте <a href="https://autohotkey.com/docs/commands/Trim.htm">Trim()</a>:<br /></p><div class="codebox"><pre><code>MsgBox,% RTrim(&quot;ФИО_&quot;, &quot;_&quot;)</code></pre></div><p><a href="https://autohotkey.com/docs/commands/StringTrimLeft.htm">StringTrimLeft / StringTrimRight</a>:<br /></p><div class="codebox"><pre><code>
str := &quot;ФИО_&quot;
StringTrimRight, str, str, 1
MsgBox,% str
</code></pre></div><p><a href="https://autohotkey.com/docs/commands/StringReplace.htm">StrReplace()</a>:<br /></p><div class="codebox"><pre><code>MsgBox,% StrReplace(&quot;ФИО_&quot;, &quot;_&quot;, &quot;&quot;)</code></pre></div><p>И пользуйтесь пожалуйста справкой, а так же, пунктуацией и оформлением в своих сообщениях, отделяя код своих примеров от текста тегом &quot;&lt;&gt;&quot; на панельке сверху текстового поля.</p>]]></content>
			<author>
				<name><![CDATA[KusochekDobra]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=33846</uri>
			</author>
			<updated>2018-05-08T12:50:55Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125218#p125218</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Удаление лишнего пробела]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=125216#p125216" />
			<content type="html"><![CDATA[<p>Добрый день! Подскажите пож-та, возможно ли удалить лишний пробел справа текста.</p><p>sleep 300<br />Xl.Range(&quot;C&quot; . Current_Row).Value := ie.document.getElementsByTagName(&quot;span&quot;)[3].innerText</p><p>Получается: ФИО_ (нижнее подчеркивание это пробел лишний). Хотелось бы сразу чтобы в скрипте делалось а, не через СЖПробелы в Excel.</p>]]></content>
			<author>
				<name><![CDATA[inseption86]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=38818</uri>
			</author>
			<updated>2018-05-08T12:04:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=125216#p125216</id>
		</entry>
</feed>
