This page is here to store notes for myself and others who are trying to use Visual Basic .NET (part of Microsoft Visual Studio,) to help automate some office tasks.
If you are writing code that could use the NATO (phonetic) alphabet and number .wav files, you are welcome to use the set of audio files recorded by Casey Walsted. This set contains the NATO alphabet, numbers, and some other words that may be useful if you are writing an application for aviation monitoring purposes. These files ARE compatble with Visual Basic.NET using the code below. I have not tested the files on VBA, but I believe they will work. If you use these files, please visibly credit her as the source. A sample file is here.
The code to play an audio file is pretty simple, assuming that the file is in the one format that Visual Basic will play directly (.wav):
My.Computer.Audio.Play("C:/SomePath/Departure.wav", AudioPlayMode.Background)
Dim xlapp As New Microsoft.Office.Interop.Excel.Application
Dim xlworkbook As Microsoft.Office.Interop.Excel.Workbook
Dim xlworksheet As Microsoft.Office.Interop.Excel.Worksheet
xlworkbook = xlapp.Workbooks.Open("C:/SomePath/Filename.xlsx")
xlworksheet = xlworkbook.Worksheets("Sheet1")
SomeVariable = xlworksheet.Cells(RowCount, ColCount).Value
xlworksheet.Cells(RowCount, ColCount).Value = SomeVariable
xlworkbook.Save()
xlworkbook.Close()
xlapp.Quit()
xlapp = Nothing
xlworkbook = Nothing
For counter=0 to 5
SomeControlBox(counter) = New TextBox
SomeControlBox(counter).Parent = Me
SomeControlBox(counter).Left = 20 + (counter * 140)
SomeControlBox(counter).Top = 50
SomeControlBox(counter).Width = 105
SomeControlBox(counter).Tag = Format(counter, "00")
AddHandler SomeControlBox(counter).Leave, AddressOf SomeControlBox_LostFocus
AddHandler SomeControlBox(counter).Enter, AddressOf SomeControlBox_Enter
Next Counter
Private Sub SomeControlBox_LostFocus(sender As Object, e As EventArgs)
ItemSelected = CInt(CStr(sender.Tag))
SomeVariable(ItemSelected) = Trim(SomeControlBox(ItemSelected).Text)
End Sub
Dim MailApp As New Microsoft.Office.Interop.Outlook.Application
Dim MailMsg As Outlook.MailItem = Nothing
MailMsg = MailApp.CreateItem(Outlook.OlItemType.olMailItem)
MailMsg.BodyFormat = Outlook.OlBodyFormat.olFormatPlain
MailMsg.Subject = "Canned Pork Product"
MailMsg.To = "PotentialCustomer@SomeRetailer.com"
MailMsg.CC = "YourBoss@YourOffice.com"
MailMsg.Body = BodyMessageStringVariable
MailMsg.Display(True)
MailApp.Quit()
MailApp = Nothing