VB runtime error 438 on running vbscript on Excel file - vba

Hi I am getting VB runtime Error code 438 and on debugging it points to below code line. I'm not sure whats wrong as this is automated script that was working earlier
Private Sub ResetView() ' Resetting the view to the default.
InitGlobalCst
Application.ScreenUpdating = False
' Untoggle the "MultiSearch buttons here.
**Sheets("Views").Multi_Case.Value = False**
Sheets("Views").Multi_CR.Value = False

Related

Excel 'Cancel' button breaks entire application

Having trouble with calling an endpoint (connectionStringURI = http:\company.com:8000/Prices?format=csv&Transaction.ID=5456, e.g.). Call it with this code:
Set curveSource = curveDestination.QueryTables.Add(Connection:="TEXT;" & connectionStringURI, Destination:=DestinationSheet.Range("A1:F3000"))
curveSource.Name = "Prices"
curveSource.TextFileParseType = xlDelimited
curveSource.TextFileCommaDelimiter = True
curveSource.Refresh BackgroundQuery:=False
curveSource.SaveData = True
The call to the URI returns a csv file. Everything works great. When this code is hit:
curveSource.Refresh BackgroundQuery:=False
I see an Excel dialogue box that says, "Contacting the server for information", and it has a 'Cancel' button on it. If the user does nothing, it displays the data properly in the DestinationSheet. If the user clicks the 'Cancel' button while this is occurring, it breaks the entire spreadsheet. From then on, it throws an error at
curveSource.Refresh BackgroundQuery:=False
The error is, "Run-time error: '1004'. Excel cannot find the text file to refresh this external data range". The user has to close the file the Excel file and reopen it to get it to work. Can't find anything about this error after hours of googling.
I've tried setting everything to Nothing, removing QueryTables, very frustrating. Nothing seems to fix the issue.
Any ideas ?
Not sure if this would help but you can try Application.DisplayAlerts = False before that line, and revert back to True afterwards maybe. And/or On Error Resume Next before the line that give the error and On Error Goto 0 afterwards.

Modify Treemap-Chart in PowerPoint

I have a chart that I modify with VBA by changing the values from an excel-workbook. Everything works fine, but I want to use the treemap-chart where suddenly the code stops working.
The code works perfectly fine with the other charts in PowerPoint but when I change it to TreeMap the Code stops executing and the chart doesn't change it values.
Option Explicit
Sub Chart_TT()
With ActivePresentation.Slides(2).Shapes("Chart 1").Chart.ChartData
.Activate
.Workbook.Sheets(2).Range("C2").Value = .Workbook.Sheets(2).Range("I9").Value
.Workbook.Sheets(2).Range("D2").Value = .Workbook.Sheets(2).Range("J9").Value
.Workbook.Sheets(2).Range("E2").Value = .Workbook.Sheets(2).Range("K9").Value
.Workbook.Sheets(2).Range("F2").Value = .Workbook.Sheets(2).Range("L9").Value
.Workbook.Close SaveChanges:=True
End With
End Sub
The error code which is shown is:
"Error -2147467259 (80004005): The method "workbook" for the object "ChartData" failed.
What do I have to change that the code also works with the TreeMap chart?
Thanks!
Sorry, the treemap chart style is fairly new and has not been included in the VBA object model.

Runtime error 429: Active X component cannot create an object

I am a newbie to vb6 and microsoft technologies. I am trying to run a vb6 application. When i open the app and try running the app, I get the following error in a dialog box "Runtime error 429: Active X component cannot create an object" and gives me two options "debug" and "end".
Environment: windows 8.1 64bit, vb6
When i click on end/debug it highlights the following code in yellow "Set m_oSNTPCtrl = CreateObject("SNTPWizard.SNTPWizardCtrl2")"..
What could be the error any missing DLL's/OCX files????
The class looks like this:
Private Sub Class_Initialize()
On Error GoTo ErrHndlr
Set m_oSNTPCtrl = CreateObject("SNTPWizard.SNTPWizardCtrl2")
m_oSNTPCtrl.UnlockSNTPWizard "SNTPWIZ-0200002100230152"
Exit Sub
ErrHndlr:
Call LogError(Err.Description, "Class_Initialize()")
End Sub

Excel VBA Procedure Error

I'm having a peculiar issue with a VBA assignment for school. The issue I'm having is VBA is giving me a compile error when Excel tries running the code at start up on a specific Workbook. It keeps telling me that the code cannot be run outside a procedure, but I don't know why it's telling me that when it needs to run at the start of the document. Here's my almost final code that's throwing the error...
Option Explicit
Worksheets("StartPage").Activate
Worksheets("Payroll").Protected
cmdDisplay.Enabled = False
cmdEmpData.Enabled = False
cmdEmployees.Enabled = True
cmdReset.Enabled = True
Public intNumEmp As Integer
That code runs BEFORE the first subroutine is run, which, aside from the variable, is throwing the error. Should I put an access modifier before them to fix the issue, or is there something else I'm missing?
#RonRosenfeld is correct, here is what the code would look like inside of the ThisWorkbook module:
Option Explicit
Public intNumEmp As Integer
Private Sub Workbook_Open()
Worksheets("StartPage").Activate
Worksheets("Payroll").Protected
cmdDisplay.Enabled = False
cmdEmpData.Enabled = False
cmdEmployees.Enabled = True
cmdReset.Enabled = True
End Sub

Closing the VBA Editor Window

I am trying to close my Visual Basic Editor window. I couldn't find any perfect code for this. These are the previous suggested codes i have tried,
1) Application.VBE.MainWindow.Close
2) Application.VBE.ActiveWindow.Close
3) Application.VBE.ActiveCodePane.Window.Close
If I run any of these codes, i am getting the following Run time error(6068)
"Programmatic Access to Visual Basic Project is not trusted".
Please tell me if there is any solution for this problem.
Application.ShowVisualBasicEditor = False
Application.VBE.MainWindow.Visible = False
tested with:
Sub hideVBE()
MsgBox "foo"
Application.VBE.MainWindow.Visible = True
MsgBox "bar"
Application.VBE.MainWindow.Visible = False
End Sub