<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBScript: нужны скрипты в Excel]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=5266&amp;type=atom" />
	<updated>2010-12-12T09:39:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=5266</id>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42821#p42821" />
			<content type="html"><![CDATA[<p>Огромное спасибо <strong>DnsIs, alexii</strong>. Все подходит, все работает. Очень сильно помогли) Не ожидал такую оперативность, и это очень приятно) И вижу тема вызвала у всех особый интерес))</p>]]></content>
			<author>
				<name><![CDATA[LDOst]]></name>
			</author>
			<updated>2010-12-12T09:39:15Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42821#p42821</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42808#p42808" />
			<content type="html"><![CDATA[<p><strong>2JSman</strong>, чего уже добились в написании Jabber-клиента? Возможно где то посмотреть?</p>]]></content>
			<author>
				<name><![CDATA[DnsIs]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26282</uri>
			</author>
			<updated>2010-12-11T17:44:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42808#p42808</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42807#p42807" />
			<content type="html"><![CDATA[<p>О, еще бы XMPP на WSH добить бы)</p>]]></content>
			<author>
				<name><![CDATA[JSmаn]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24434</uri>
			</author>
			<updated>2010-12-11T16:24:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42807#p42807</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42805#p42805" />
			<content type="html"><![CDATA[<p><strong>2 alexii</strong> <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /> в следующий раз когда будет бессонница, загляните в комьюнити в ветку расчёта аннуитета, может по утру и темку закроем <img src="//forum.script-coding.com/img/smilies/big_smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Евген]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25253</uri>
			</author>
			<updated>2010-12-11T14:25:39Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42805#p42805</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42794#p42794" />
			<content type="html"><![CDATA[<p><strong>jite</strong>, это была бессонница. Плюс два с половиной часа попыток выложить поутру скрипт на форум.</p><p>На самом деле, более правильный подход к вопросу продемонстрировал коллега <strong>DnsIs</strong> — ровно то, что заказывали (я не пробовал загружать файл, но визуально, по коду, — должно работать).</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2010-12-11T00:35:01Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42794#p42794</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42786#p42786" />
			<content type="html"><![CDATA[<p>Я просто в... <img src="//forum.script-coding.com/img/smilies/yikes.png" width="15" height="15" /><br />В 2 ночи некто выражает желание получить анимацию в Excel: и чтобы квадрат, и чтобы по траектории, и ... см. выше.<br />А к 10 утра уже выложена реализация всего этого плюс в цвете и с вращением (ну чтоб не скучно было).</p><p>Нет, я понимаю, бывает, долго ли умеючи... Но у меня, зрителя со стороны, вызывает оторопелое опупение, когнитивный диссонанс и бурное восхищение.</p><p><strong>alexii</strong>, это был экспромт или все-таки заготовка?</p>]]></content>
			<author>
				<name><![CDATA[jite]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=25851</uri>
			</author>
			<updated>2010-12-10T19:27:57Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42786#p42786</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42757#p42757" />
			<content type="html"><![CDATA[<p><strong>LDOst</strong>, уточняйте.</p><p>В одном флаконе (проверялось на «Microsoft Office 2003»):<br /></p><div class="codebox"><pre><code>Option Explicit

Const xlMaximized             = &amp;HFFFFEFD7

&#039; Some of Enum MsoAutoShapeType
Const msoShapeRectangle       =  1
Const msoShapeDiamond         =  4

&#039; Some Shape styles
Const msoShadow14             = 14
Const msoThreeD1              =  1
Const msoLineSolid            =  1
Const msoLineRoundDot         =  3
Const msoLineSingle           =  1
Const msoTrue                 = &amp;HFFFFFFFF
Const msoGradientDiagonalDown =  4

&#039; Some of Enum MsoPresetGradientType
Const msoGradientRainbow      = 16
Const msoGradientRainbowII    = 17

&#039; Some of Enum MsoPresetExtrusionDirection
Const msoExtrusionBottomRight =  1
Const msoExtrusionBottom      =  2
Const msoExtrusionBottomLeft  =  3
Const msoExtrusionRight       =  4
Const msoExtrusionNone        =  5
Const msoExtrusionLeft        =  6
Const msoExtrusionTopRight    =  7
Const msoExtrusionTop         =  8
Const msoExtrusionTopLeft     =  9

&#039; Some of Enum XlMousePointer
Const xlDefault               = &amp;HFFFFEFD1
Const xlWait                  =  2


Dim objExcel
Dim objCommandBar
Dim dictCommandBars
Dim i

Dim sngStartCoord
Dim sngFlySize
Dim sngFigureSize

Dim sngStep
Dim sngSqrt2
Dim intExtrDirectionSquare
Dim intExtrDirectionRhombus

Dim objShapeSquare
Dim objShapeRhombus


Set objExcel        = WScript.CreateObject(&quot;Excel.Application&quot;)
Set dictCommandBars = WScript.CreateObject(&quot;Scripting.Dictionary&quot;)

With objExcel
    .Visible           = True
    .UserControl       = True
    
    .Cursor            = xlWait
    .Interactive       = False
    .ScreenUpdating    = False
    
    .WindowState       = xlMaximized
    
    .DisplayFormulaBar = False
    .DisplayStatusBar  = False
    
    .SheetsInNewWorkbook = 1
    
    For Each objCommandBar In .CommandBars
        If objCommandBar.Visible Then
            dictCommandBars.Add objCommandBar.Name, objCommandBar
            objCommandBar.Enabled = False
        End If
    Next
    
    With .Workbooks.Add
        With .ActiveSheet
            With .Application.ActiveWindow
                .DisplayGridlines           = False
                .DisplayHeadings            = False
                .DisplayOutline             = False
                .DisplayHorizontalScrollBar = False
                .DisplayVerticalScrollBar   = False
                .DisplayWorkbookTabs        = False
            End With
            
            sngStartCoord = 100
            sngFlySize    = 360
            sngFigureSize =  50
            
            With .Shapes.AddShape(msoShapeRectangle, sngStartCoord + sngFigureSize / 2, sngStartCoord + sngFigureSize / 2, sngFlySize, sngFlySize)
                With .Line
                    .Weight                = 0.25
                    .DashStyle             = msoLineSolid
                    .Style                 = msoLineSingle
                    .Transparency          = 0
                    .ForeColor.SchemeColor = 24
                    .Visible               = msoTrue
                End With
            End With
            
            With .Shapes.AddShape(msoShapeDiamond, sngStartCoord + sngFigureSize / 2, sngStartCoord + sngFigureSize / 2, sngFlySize, sngFlySize)
                With .Line
                    .Weight                = 0.25
                    .DashStyle             = msoLineSolid
                    .Style                 = msoLineSingle
                    .Transparency          = 0
                    .ForeColor.SchemeColor = 41
                    .Visible               = msoTrue
                End With
            End With
            
            intExtrDirectionSquare  = msoExtrusionBottomRight
            intExtrDirectionRhombus = msoExtrusionRight
            
            Set objShapeSquare = .Shapes.AddShape(msoShapeRectangle, sngStartCoord, sngStartCoord, sngFigureSize, sngFigureSize)
            SetShape objShapeSquare, 1, intExtrDirectionSquare
            
            Set objShapeRhombus = .Shapes.AddShape(msoShapeRectangle, sngStartCoord, sngStartCoord + sngFlySize / 2, sngFigureSize, sngFigureSize)
            SetShape objShapeRhombus, 2, intExtrDirectionRhombus
            objShapeRhombus.IncrementRotation 45
            
            .Application.ScreenUpdating = True
            WScript.Sleep 1000
            
            sngStep  = 3
            sngSqrt2 = Sqr(sngStep^2 + sngStep^2) / sngStep
            
            For i = 1 To sngFlySize Step sngStep
                If i &gt;= sngFlySize / 3 * 2 Then
                    intExtrDirectionSquare  = msoExtrusionBottomLeft
                    intExtrDirectionRhombus = msoExtrusionTop
                ElseIf i &gt;= sngFlySize / 3 Then
                    intExtrDirectionSquare  = msoExtrusionBottom
                    intExtrDirectionRhombus = msoExtrusionTopRight
                End If
                
                MoveShape objShapeSquare,   sngStep,          0, -sngStep, intExtrDirectionSquare
                MoveShape objShapeRhombus,  sngSqrt2,  sngSqrt2,  sngStep, intExtrDirectionRhombus
            Next
            
            For i = 1 To sngFlySize Step sngStep
                If i &gt;= sngFlySize / 3 * 2 Then
                    intExtrDirectionSquare  = msoExtrusionTopLeft
                    intExtrDirectionRhombus = msoExtrusionLeft
                ElseIf i &gt;= sngFlySize / 3 Then
                    intExtrDirectionSquare  = msoExtrusionLeft
                    intExtrDirectionRhombus = msoExtrusionTopLeft
                End If
                
                MoveShape objShapeSquare,          0,  sngStep,  -sngStep, intExtrDirectionSquare
                MoveShape objShapeRhombus,  sngSqrt2, -sngSqrt2,  sngStep, intExtrDirectionRhombus
            Next
            
            For i = 1 To sngFlySize Step sngStep
                If i &gt;= sngFlySize / 3 * 2 Then
                    intExtrDirectionSquare  = msoExtrusionTopRight
                    intExtrDirectionRhombus = msoExtrusionBottom
                ElseIf i &gt;= sngFlySize / 3 Then
                    intExtrDirectionSquare  = msoExtrusionTop
                    intExtrDirectionRhombus = msoExtrusionBottomLeft
                End If
                
                MoveShape objShapeSquare,  -sngStep,          0, -sngStep, intExtrDirectionSquare
                MoveShape objShapeRhombus, -sngSqrt2, -sngSqrt2,  sngStep, intExtrDirectionRhombus
            Next
            
            For i = 1 To sngFlySize Step sngStep
                If i &gt;= sngFlySize / 3 * 2 Then
                    intExtrDirectionSquare  = msoExtrusionBottomRight
                    intExtrDirectionRhombus = msoExtrusionRight
                ElseIf i &gt;= sngFlySize / 3 Then
                    intExtrDirectionSquare  = msoExtrusionRight
                    intExtrDirectionRhombus = msoExtrusionBottomRight
                End If
                
                MoveShape objShapeSquare,          0, -sngStep,  -sngStep, intExtrDirectionSquare
                MoveShape objShapeRhombus, -sngSqrt2,  sngSqrt2,  sngStep, intExtrDirectionRhombus
            Next
            
            WScript.Sleep 1000
            
            With .Application.ActiveWindow
                .DisplayGridlines           = True
                .DisplayHeadings            = True
                .DisplayOutline             = True
                .DisplayHorizontalScrollBar = True
                .DisplayVerticalScrollBar   = True
                .DisplayWorkbookTabs        = True
            End With
        End With
        
        .Saved = True
    End With
    
    For Each objCommandBar In dictCommandBars.Items
        objCommandBar.Enabled = True
    Next
    
    .Interactive       = True
    .Cursor            = xlDefault
    
    .DisplayFormulaBar = True
    .DisplayStatusBar  = True
End With

Set dictCommandBars = Nothing
Set objExcel        = Nothing

WScript.Quit 0
&#039;=============================================================================

&#039;=============================================================================
Sub MoveShape(objShape, sngIncLeft, sngIncTop, sngIncRotate, intExtrDirection)
    With objShape
        .IncrementLeft                sngIncLeft
        .IncrementTop                 sngIncTop
        .IncrementRotation            sngIncRotate
        .ThreeD.SetExtrusionDirection intExtrDirection
    End With
End Sub
&#039;=============================================================================

&#039;=============================================================================
Sub SetShape(objShape, intType, intExtrDirection)
    With objShape
        With .Line
            .Weight                = 0.25
            .DashStyle             = msoLineRoundDot
            .Style                 = msoLineSingle
            .Transparency          = 0
            .ForeColor.SchemeColor = 24
            .BackColor.RGB         = RGB(255, 255, 255)
            .Visible               = msoTrue
        End With
        
        With .Fill
            .Transparency          = 0
            
            Select Case intType
                Case 1
                    .ForeColor.RGB  = RGB(255, 51, 153)
                    .BackColor.RGB  = RGB(51, 102, 255)
                    .PresetGradient   msoGradientDiagonalDown, 2, msoGradientRainbowII
                Case 2
                    .ForeColor.RGB  = RGB(166, 3, 171)
                    .BackColor.RGB  = RGB(166, 3, 171)
                    .PresetGradient   msoGradientDiagonalDown, 1, msoGradientRainbow
                Case Else
                    &#039; Nothing to do
            End Select
            
            .Visible                = msoTrue
        End With
        
        With .ThreeD
            .ExtrusionColor.RGB     = RGB(204, 236, 255)
            .SetThreeDFormat          msoThreeD1
            .SetExtrusionDirection    intExtrDirection
            .Perspective            = True
            .Depth                  = 72
            .Visible                = msoTrue
        End With
    End With
End Sub
&#039;=============================================================================</code></pre></div>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2010-12-10T05:46:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42757#p42757</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42753#p42753" />
			<content type="html"><![CDATA[<p>В макросах экселевских ничего не понимаю, но погуглив и попыхтев получилось вот что:</p><div class="codebox"><pre><code>Sub newFigure()
    ActiveSheet.Shapes.AddShape(msoShapeRectangle, 200, 200, 50, 50).Select
    Selection.Name = &quot;fig&quot;
End Sub

Sub Run1()
    ActiveSheet.Shapes(&quot;fig&quot;).Select
    x = 0.75
    y = 0
    For k = 1 To 1600
        Selection.ShapeRange.IncrementLeft x
        Selection.ShapeRange.IncrementTop y
        Application.Wait (2)
        If k = 400 Then
            x = 0
            y = 0.75
        End If
        If k = 800 Then
            x = -0.75
            y = 0
        End If
        If k = 1200 Then
            x = 0
            y = -0.75
        End If
    Next k

End Sub

Sub Run2()
    ActiveSheet.Shapes(&quot;fig&quot;).Select
    x = 1
    y = 0.75
    For k = 1 To 800
        Selection.ShapeRange.IncrementLeft x
        Selection.ShapeRange.IncrementTop y
        Application.Wait (2)
        If k = 200 Then
            x = -1
        End If
        If k = 400 Then
            y = -0.75
        End If
        If k = 600 Then
            x = 1
        End If
    Next k
End Sub</code></pre></div><p>Работает отличненько (если я правильно понял поставленную вами задачу). Залил файл на пару бесплатных файлохранилищ, можете скачать проверить. <a href="http://rghost.ru/3549592">Здесь</a> или <a href="http://zalil.ru/30113591">тут</a></p><p>Помог материал <a href="http://www.rosinka.vrn.ru/dinex/dvig_ob.htm">отсюда</a></p>]]></content>
			<author>
				<name><![CDATA[DnsIs]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26282</uri>
			</author>
			<updated>2010-12-10T04:58:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42753#p42753</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42748#p42748" />
			<content type="html"><![CDATA[<p>У меня уточнений по задаче больше нет, но думаю, что на рабочем листе. А так как будет удобнее сделать.</p>]]></content>
			<author>
				<name><![CDATA[LDOst]]></name>
			</author>
			<updated>2010-12-09T22:33:05Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42748#p42748</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42746#p42746" />
			<content type="html"><![CDATA[<p>Прошу срочно разъяснить, где именно должен рисоваться и двигаться квадрат? На форме? На рабочем листе (что в таком случае понимать под квадратом)? Зачем Вам это вообще нужно? Прошу срочно ответить. <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2010-12-09T22:05:07Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42746#p42746</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBScript: нужны скрипты в Excel]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=42745#p42745" />
			<content type="html"><![CDATA[<p>Нужна программа(в VBS) чтоб в Excel рисовался небольшой квадрат, и он двигался строго по квадратной траектории, и вторая программа тоже самое, но по траектории ромба.<br />Сам ни разу не програмировал, что-то подобное, по этому даже не прдствалю как сделать, не много работал в VB... Прошу срочно помочь.</p>]]></content>
			<author>
				<name><![CDATA[LDOst]]></name>
			</author>
			<updated>2010-12-09T21:05:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=42745#p42745</id>
		</entry>
</feed>
