Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Conversion HELP!


  • Please log in to reply

#1
petedw

petedw

    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
Next
ComboBox1.ListIndex = 0

End Sub

Private Sub ComboBox1_Change()

ComboBox2.Clear
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
Next
If ComboBox2.ListCount > 0 Then ComboBox2.ListIndex = 0

End Sub

Private Sub ComboBox2_Change()

ComboBox3.Clear
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
Next
If ComboBox3.ListCount > 0 Then ComboBox3.ListIndex = 0

End Sub


Private Sub ComboBox3_Change()

ComboBox4.Clear
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
Next
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

Pete
  • 0

Advertisements







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