ClimoC
Well-known Member
- Joined
- Aug 21, 2009
- Messages
- 584
Hello
Had some handy code working, and then to make things neat and tidy and easier to give to users across the network, I've moved it all into a userform.
Upon clicking the button, it should open an inputbox, take the answer as a string, and use it to find a folder of that name where some modules are kept to import to the Personal.xls file.
Problem is that stepping through the code, it seems to think that when I enter "Hamburger", that the string "Hamburger" = vbCancel is TRUE. Which, last time I checked, it effin'-isn't.
Last line of the code below
if you enter the string as "CS__" it works, if you enter "GENE", it works, but enter anything else, and it seems to think that vbCancel = True.
Had some handy code working, and then to make things neat and tidy and easier to give to users across the network, I've moved it all into a userform.
Upon clicking the button, it should open an inputbox, take the answer as a string, and use it to find a folder of that name where some modules are kept to import to the Personal.xls file.
Problem is that stepping through the code, it seems to think that when I enter "Hamburger", that the string "Hamburger" = vbCancel is TRUE. Which, last time I checked, it effin'-isn't.
Last line of the code below
Code:
Private Sub CommandButton2_Click()
On Error Resume Next
Application.VBE.VBProjects(1).References.AddFromGuid _
GUID:="{0002E157-0000-0000-C000-000000000046}", _
Major:=5, Minor:=3
Err.Clear
Call MYimport
End Sub
Sub MYimport()
Application.ScreenUpdating = False
Dim DAddress As String
Dim BAddress As String
Dim x As Integer
'Base address for all the macro sub-folders
BAddress = "\\Server\Schedules\MSExcel\Company Schedule\macros"
'Activates the Microsoft Extensibility reference pack
On Error Resume Next
Application.VBE.VBProjects(1).References.AddFromGuid _
GUID:="{0002E157-0000-0000-C000-000000000046}", _
Major:=5, Minor:=3
Err.Clear
'Resulting string from the following input box will provide the basis for removing old modules, fetching the new ones, and adding
'macros to the toolbar. The naming convention is strict, but simple. Whatever 4 characters are used, they must
Dim answer As String
answer = InputBox("Please enter the 4 character acronym for your dept" & Chr(10) & _
"If your dept's acronym is fewer than 4 characters, make up the difference with " & Chr(10) & _
"underscores ('_')." & Chr(10) & _
"(e.g., If Show acronym is 'SP', enter 'SP__')")
If answer = "CS__" Then
Run "CSimports"
Application.ScreenUpdating = True
Exit Sub
ElseIf answer = "GENE" Then
Run "GENEimports"
Application.ScreenUpdating = True
Exit Sub
ElseIf answer = vbCancel Then
Exit Sub
End If
if you enter the string as "CS__" it works, if you enter "GENE", it works, but enter anything else, and it seems to think that vbCancel = True.