ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   error while compiling "OBJECT REQUIRED" (https://www.excelbanter.com/excel-discussion-misc-queries/64735-error-while-compiling-object-required.html)

nuti

error while compiling "OBJECT REQUIRED"
 
hi,

iam trying to run a macro in the excel but its throwing error "object
required".
kindly help me out .

THE ERROR IS SHOWN FOR THE LAST LINE OF CODE.

-------------------------------------------------------------------------------------------------------
Dim objWSH As String, objFileSystem, objlogfile As String
Dim strWorkPath, lCountErrors, lCountWarnings, strLogFileName,
strLogDate As String
Dim strDHCPServer, strIPAddr, strMACAddr, strScope, strClientName,
strComment, strtype As String
Dim strOption, strOptionCode, strOptionValue, strDNSvalues As String
Dim fso, DHCPInputFile, strLine, varLine, posFirstParam, strFirstParam
As String
Dim strNewLine, posSecondParam, strSecondParam, strThirdParam As String
Dim strInputboxText, intInput, strInputFile, strRegion, strMsgboxText,
intMsgbox As String


Set objWSH = WScript.CreateObject("Wscript.shell")
Set objFileSystem = WScript.CreateObject("Scripting.FileSystemObject")

strWorkPath = objFileSystem.GetParentFolderName(WScript.ScriptFu llName)
'Set working directory


'Logfile configuration
strLogDate = GetLogDate
strLogFileName = objWSH.ExpandEnvironmentStrings(strWorkPath & "\" &
strLogDate & ".log")
Set objlogfile = objFileSystem.CreateTextFile(strLogFileName, True)



-------------------------------------------------------------------------------------------------------


Dave Peterson

error while compiling "OBJECT REQUIRED"
 
You declared:
objlogfile As String
how about:
objlogfile As Object



nuti wrote:

hi,

iam trying to run a macro in the excel but its throwing error "object
required".
kindly help me out .

THE ERROR IS SHOWN FOR THE LAST LINE OF CODE.

-------------------------------------------------------------------------------------------------------
Dim objWSH As String, objFileSystem, objlogfile As String
Dim strWorkPath, lCountErrors, lCountWarnings, strLogFileName,
strLogDate As String
Dim strDHCPServer, strIPAddr, strMACAddr, strScope, strClientName,
strComment, strtype As String
Dim strOption, strOptionCode, strOptionValue, strDNSvalues As String
Dim fso, DHCPInputFile, strLine, varLine, posFirstParam, strFirstParam
As String
Dim strNewLine, posSecondParam, strSecondParam, strThirdParam As String
Dim strInputboxText, intInput, strInputFile, strRegion, strMsgboxText,
intMsgbox As String

Set objWSH = WScript.CreateObject("Wscript.shell")
Set objFileSystem = WScript.CreateObject("Scripting.FileSystemObject")

strWorkPath = objFileSystem.GetParentFolderName(WScript.ScriptFu llName)
'Set working directory

'Logfile configuration
strLogDate = GetLogDate
strLogFileName = objWSH.ExpandEnvironmentStrings(strWorkPath & "\" &
strLogDate & ".log")
Set objlogfile = objFileSystem.CreateTextFile(strLogFileName, True)

-------------------------------------------------------------------------------------------------------


--

Dave Peterson


All times are GMT +1. The time now is 06:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com