Solved

Problem to the item

Posted on 2015-01-27
2
96 Views
Last Modified: 2015-01-28
Hi,
I don't know why I get the error attached,

to these codes
Public Function vbascr2main() Set objFSO=CreateObject("Scripting.FileSystemObject") : out1="z:\cmp2\list1.txt" : Set objFile = objFSO.CreateTextFile(out1,True) : Dim x1 : For each x1 in AVX.Item : objFile.Write x1.Name & "<br />" : Next : objFile.Close : End Function

Open in new window

0
Comment
Question by:HuaMinChen
2 Comments
 
LVL 45

Expert Comment

by:aikimark
ID: 40574464
Try this.
Public Function vbascr2main() 
  Set objFSO=CreateObject("Scripting.FileSystemObject")
  out1="z:\cmp2\list1.txt"
  Set objFile = objFSO.CreateTextFile(outFile,True)
  Dim x1
  For each x1 in AVX.Item
    objFile.WriteLine x1.Name
  Next
  objFile.Close
End Function

Open in new window

0
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 500 total points
ID: 40574469
At first glance I don't see AVX as defined in your code  Therefore it will error when you try and loop through it.  I also don't recommend putting all that in one line of code as it makes it for someone who follows you to to read it.  I recommend you break it down, something like this:

Public Function vbascr2main()
	Dim x1

	Set objFSO=CreateObject("Scripting.FileSystemObject")
	out1="z:\cmp2\list1.txt"
	Set objFile = objFSO.CreateTextFile(out1,True)

	For each x1 in AVX.Item
		objFile.Write x1.Name & "<br />"
	Next
	
	objFile.Close
End Function

Open in new window


What error do you receive?
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question