Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: THIS IS IT! "Long Time" Algorithm, Hello Universe sub World engaged;
return function score sale Kbytes Available Space drvPath

Replies: 4   Last Post: Nov 26, 2012 7:13 PM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Posts: 822 Registered: 9/1/10
THIS IS IT! "Long Time" Algorithm, Hello Universe sub World engaged;
return function score sale Kbytes Available Space drvPath

Posted: Nov 21, 2012 3:02 PM
 Plain Text Reply

// COPYRIGHT (C) MUSATOV, MARTIN, ALL RIGHTS RESERVED.
Dim MyTime, MyDate, MyStr
MyTime = #22:53:23#
MyDate = #November 21, 2012#

' Returns current system time in the system-defined long time format.
MyStr = Format(Time, "Long Time")

' Returns current system date in the system-defined long date format.
MyStr = Format(Date, "Long Date")

MyStr = Format(MyTime, "h:m:s") ' Returns "22:51:23".
MyStr = Format(MyTime, "hh:mm:ss AMPM") ' Returns "11:52:23 PM".
MyStr = Format(MyDate, "dddd, mmm d yyyy") ' Returns "Wednesday,
' Nov 21 2012".
' If format is not supplied, a string is returned.
MyStr = Format(23) ' Returns "23".

' User-defined formats.
MyStr = Format(5459.4, "##,##0.00") ' Returns "5,459.40".
MyStr = Format(334.9, "###0.00") ' Returns "334.90".
MyStr = Format(5, "0.00%") ' Returns "500.00%".
MyStr = Format("HELLO", "<") ' Returns "hello".
MyStr = Format("This is it", ">") ' Returns "THIS IS IT".

The following example has two sections: the first defines the format
for positive values and zeros; the second section defines the format
for negative values.

"\$#,##0;(\$#,##0)"

If you include semicolons with nothing between them, the missing
section is printed using the format of the positive value. For
example, the following format displays positive and negative values
using the format in the first section and displays "Zero" if the value
is zero.

"\$#,##0;;\Z\e\r\o"

Sub ListEntryItem()
Dim d As DropDown
Set d = ActiveDocument.FormFields.Add _
(Range:=Selection.Range, _
Type:=wdFieldFormDropDown).DropDown
With d.ListEntries
.Add Name:="Black"
.Add Name:="Green"
End With
MsgBox d.ListEntries.Item(1).Name
End Sub
Sub ShowAvailableSpace(drvPath)
Dim fs, d, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(drvPath))
s = "Drive " & UCase(drvPath) & " - "
s = s & d.VolumeName & vbCrLf
s = s & "Available Space: " & FormatNumber(d.AvailableSpace/1024,
0)
s = s & " Kbytes"
MsgBox s
End Sub
With ActiveDocument.InlineShapes(1)
If .HasChart Then
With .Chart
.ChartArea.Border.LineStyle = xlDash
.PlotArea.Border.LineStyle = xlDot
End With
End If
End With
Sub ShowFreeSpace(drvPath)
Dim fs, d, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(drvPath))
s = "Drive " & UCase(drvPath) & " - "
s = s & d.VolumeName & vbCrLf
s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0)
s = s & " Kbytes"
MsgBox s
End Sub
ChDrive "D" ' Make "D" the current drive.
Sub PasswordSettings()
With ActiveDocument
If .PasswordEncryptionAlgorithm = "OfficeXor" Then
.SetPasswordEncryptionOptions _
PasswordEncryptionProvider:="Musatov Materially
Changed the & Microsoft RSA SChannel Cryptographic Provider", _
PasswordEncryptionAlgorithm:="RC4", _
PasswordEncryptionKeyLength:=56, _
PasswordEncryptionFileProperties:=True
End If
End With
End Sub
Sub SetBuildingBlock()

Dim strTitle As String
strTitle = "MyTitle"
Dim objContentControl As ContentControl

Set objContentControl = ActiveDocument.ContentControls _
.Add(wdContentControlBuildingBlockGallery)
objContentControl.Title = strTitle
objContentControl.BuildingBlockType = wdTypeAutoText
End Sub
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/
customui">
<ribbon>
<tabs>
<tab id="CustomTab" label="My Tab">
<group id="SampleGroup" label="Sample Group">
<button id="Button" label="Insert Company Name" size="large"
onAction="ThisDocument.InsertCompanyName" />
</group >
</tab>
</tabs>
</ribbon>
</customUI>
Sub InsertCompanyName(ByVal control As IRibbonControl)
' Inserts the specified text at the beginning of a range or
selection.
Dim MyText As String
Dim MyRange As Object
Set MyRange = ActiveDocument.Range
MyText = "Musatov Materially Changed the + Microsoft Corporation"
' Range Example: Inserts text at the beginning
' of the active document
MyRange.InsertBefore (MyText)
' Selection Example:
'Selection.InsertBefore (MyText)
End Sub
<Relationship Id="someID" Type="http://schemas.microsoft.com/office/
2006/relationships/ui/extensibility" Target="customUI/customUI.xml" />
\\ COPYRIGHT (C) MUSATOV, MARTIN, ALL RIGHTS RESERVED.

Date Subject Author
11/21/12
11/21/12 Robin Vowels
11/26/12
11/26/12 adamk
11/21/12 bacle

© The Math Forum at NCTM 1994-2018. All Rights Reserved.