I'm getting the error:
cdo.message.1 error 800cce05 The requested body part was not found in this message
when the page gets to the 2nd line of the code:
set objMail=createobject("CDO.Message")
objMail.From="email"
ObjMail.To="email"
ObjMail.Subject= "Hello"
ObjMail.TextBody="some text"
objMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="my smtp provider"
objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusername")="my username"
objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword")="my password"
objMail.Configuration.Fields.Update
ObjMail.Send
set objMail=Nothing
This code is OK and running on other machines, one is exactly the same as on windows 10.
Please advise how to resolve this error.
Related
I am trying to record a macro to refresh a sql connection file using a single button in vba but it comes up with an error. On hitting the refresh button to which I have assigned the macro, it says
Run time error 91 - You attempted to use an object variable that isn't yet referencing a valid object.
Sub RefreshCRS610()
'
' RefreshCRS610 Macro
'
'
With Selection.ListObject.QueryTable
.Connection = Array( _
"OLEDB;Provider=SQLOLEDB.1;Password=FDReport;Persist Security Info=True;User ID=FDReport;Initial Catalog=M6FDBGRP;Data Source=mlirvcb00" _
, _
"1;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=FXV10084;Use Encryption for Data=False;Tag w" _
, "ith column collation when possible=False")
.CommandType = xlCmdSql
.CommandText = Array( _
"SELECT DISTINCT OKCONO As 'Company Number', OKCUNO As 'Customer Number', OKSTAT As 'Status', OKRESP As 'Branch Resp" _
, "onsible' FROM M6FDBGRP.MPXFDTA.OCUSMA")
.Refresh BackgroundQuery:=False
End With
End Sub
I was trying to automate refreshing the sql connection table without hitting right click-> edit query->table->okay-> enter pwd again and again. Trying to just refresh the azure sql database table by one click.
Run time error 91 - You attempted to use an object variable that isn't yet referencing a valid object.
Try getting the valid Selection object instance from the Application or ActiveWorksheet instances.
I am trying to suppress the following message box from occurring or have it go to the error message line if it does occur. " Sorry we couldn't find xxx is it possible if it was moved..."
Normally I would check if the dir(Folderpath & Filename) <> 0. However, these files are on a sharepoint server. So regardless of whether the files exist or not I get a runtime 52 error:
"Error 52: Bad filename or number." This error occurs when launching an FRx install that points to a network SysData directory."
Where I am confused is the below snippet works if the file exist.
Set stateWb = Workbooks.Open(folderPath & fileName)
However, if it does not exist I receive the " Sorry we couldn't find xxx is it possible if it was moved...". The goal is that if the workbooks.open fails, go to error message and print the following msgBox " State Data not available".
Currently it does both it gives the message " Sorry we couldn't find xxx is it possible if it was moved..." and also produces the msgbox " State Data not available".
Thoughts?
You can avoid the "Sorry we couldn't find xxx is it possible if it was moved..." error by using:
On Error GoTo error_Check
...code...
Set stateWb = Workbooks.Open(folderPath & fileName)
...code...
error_Check:
MsgBox "State Data not available"
However, in this case any error in the procedure will go here so...
I'm trying to use the following formula, but am getting the error application defined or object defined error. I have a feeling it's due to the line break, but it looks good to me.
ActiveCell.FormulaR1C1 = _
"=IF(AND(R[1]C[-13]=RC[-13],R[1]C[-15]=RC[-15]),IF(AND(R[1]C[-8]=RC[-8],R[1]C[-3]<>RC[-3]),IF(AND(R[2]C[-8]=R[1]C[-8],R[2]C[-3]<>R[1]C[-3]),IF(AND(R[3]C[-8]=R[2]C[-8],R[3]C[-3]<>R[2]C[-3]),IF(AND(R[4]C[-13]=R[3]C[-13],R[4]C[-15]=R[3]C[-15]),"""",RC[-3]),IF(AND(R[3]C[-13]=R[2]C[-13],R[3]C[-15]=R[2]C[-15]),"""",RC[-3]))," & _
"IF(AND(R[2]C[-13]=R[1]C[-13],R[2]C[-15]=R[1]C[-15],"""",RC[-3])),""""),IF(RC[-3]="""","""",RC[-3]))"
I want to get status of a Application Pool. I have vbscript taken from here.
strArgAppPool = Wscript.Arguments.Unnamed.Item(0)
Const noError = False
' Establish the connection to the WMI provider
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Search the AppPool passed as argument in the list of application pools
Set oAppPool = oWebAdmin.Get("ApplicationPool.Name='" & strArgAppPool & "'")
' Create nice messages for pool states
Select Case oAppPool.GetState
Case 0
StateDescription = "STARTING"
outputStatus = "WARNING! "
outputCode = 1
Case 1
StateDescription = "STARTED"
outputStatus = "OK! "
outputCode = 0
Case 2
StateDescription = "STOPPING"
outputStatus = "WARNING! "
outputCode = 1
Case 3
StateDescription = "STOPPED"
outputStatus = "CRITICAL!! "
outputCode = 2
Case 4
StateDescription = "UNKNOWN"
outputStatus = "UNKNOWN? "
outputCode = 3
Case Else
StateDescription = "UNDEFINED VALUE"
outputStatus = "UNKNOWN? "
outputCode = 3
End Select
' Output
Wscript.Echo outputStatus & oAppPool.Name & ": " & StateDescription
' Error handling
If noError = true Then
' Error message
Wscript.echo "UNKNOWN: Error during the WMI query for app pool " & strArgAppPool & " !"
' Exit & return code
WScript.Quit(3)
Else
' Clean exit
WScript.Quit(outputCode)
End If
Through a batch file I am trying to run it as
status1.vbs "DefaultAppPool"
But I ended up with this
Is it some service is not started? I have tried running the vb script directly. I have tried passing arguments without quotes and all similar stuff. I don't write scripts, but got to do it this time.
Error dialog indicates line 5, Set oWebAdmin = GetObject("winmgmts:root\WebAdministration"). I have tried everything I could in last 5 hours. I have a readymade script and I am not able to run it. Shame and was not willing post this question all this while. But lost in end. Thanks for any help.
Also I have a working script for IIS 6. I am calling this script through PsExec on a remote server. But that's not working in IIS 7. Let me know if anyone want me to post it. Also I am using IIS 7 and Server 2008 R2 now and will be running this script using PsExec on remote server.
You don't have the role service IIS Management Scripts and Tools installed. Launch Server Manager, go to Roles → Web Server (IIS), and install the missing service.
is there a way to display a 2 or 3 or 4 or n line message on a pop-up window in vba 6 ?
For the moment my pop-up window ( calling the MsgBox function) displays the message like this :
You did something wrong. Please enter valid input.
and I want it to display the message like this
You did something wrong.
Please enter valid input.
can you please provide a code sample?
many thx in advance,
radu
Just add a newline in your message:
MsgBox "Text 1" & vbNewLine & "text 2.
Relatively easy request
iResult = MsgBox("This information is on the first line. " & vbCrLf & "This information is on the 2nd line. " &vbCrLf & _
"Do you wish to continue?", vbYesNo + vbInformation, "Message Box")