Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

Conversion HELP!

  • Please log in to reply



    New Member

  • Member
  • Pip
  • 1 posts
Hi guys,

Can anyone convert this code i wrote using Visual Basic In Microsoft Word into C# coding. I would be very grateful!

Option Explicit

Const strStartFldr As String = "P:\Production Files\Utilities Production\Centrica\centrica to sort\GasCare LP\"
Dim fso, froot, fldr, f

Private Sub UserForm_Initialize()

Set fso = CreateObject("Scripting.FileSystemObject")
Set froot = fso.GetFolder(strStartFldr)
For Each fldr In froot.SubFolders
If fldr.Name = "LP Electricity Bills" Or fldr.Name = "LP Electricity Statements" Or fldr.Name = "LP Gas Accounts" Or fldr.Name = "LP Gas Bills" Then
ComboBox1.AddItem fldr.Name
End If
ComboBox1.ListIndex = 0

End Sub

Private Sub ComboBox1_Change()

Set froot = fso.GetFolder(strStartFldr & ComboBox1.Text)
For Each fldr In froot.SubFolders
If fldr.Name = "New System" Then
ComboBox2.AddItem fldr.Name
End If
If ComboBox2.ListCount > 0 Then ComboBox2.ListIndex = 0

End Sub

Private Sub ComboBox2_Change()

Set froot = fso.GetFolder(strStartFldr & ComboBox1.Text & "\" & ComboBox2.Text)
For Each fldr In froot.SubFolders
If fldr.Name = "British" Or fldr.Name = "Scottish" Or fldr.Name = "Welsh" Then
ComboBox3.AddItem fldr.Name
End If
If ComboBox3.ListCount > 0 Then ComboBox3.ListIndex = 0

End Sub

Private Sub ComboBox3_Change()

Set froot = fso.GetFolder(strStartFldr & ComboBox1.Text & "\" & ComboBox2.Text & "\" & ComboBox3.Text)
For Each f In froot.Files
If UCase(Right(f.Name, 3)) = "DOT" Then
ComboBox4.AddItem f.Name
End If
If ComboBox4.ListCount > 0 Then ComboBox4.ListIndex = 0

End Sub

Private Sub CommandButton1_Click()

Dim myRange As Range

Documents.Open (strStartFldr & ComboBox1.Text & "\" & ComboBox2.Text & "\" & ComboBox3.Text & "\" & ComboBox4.Text), ReadOnly:=True
Unload Me
'MsgBox ActiveDocument
SendKeys "%{TAB}", True
SendKeys "%{TAB}", True
SendKeys "{DOWN}", True
SendKeys "{UP}", True
End Sub

Private Sub UserForm_Terminate()

Set f = Nothing
Set fldr = Nothing
Set froot = Nothing
Set fso = Nothing

End Sub

Many Thanks

  • 0


Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP