What is wrong with my code

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
' write to temp file
usr = Environ("username")
strTempFile = "C:\Users\" & usr & "\Desktop\Master.xml"
With CreateObject("Scripting.FileSystemObject")
' true to overwrite existing temp file
.CreateTextFile(strTempFile, True).write strData

End With

This is just a part of the code. Everytime I run the code stops at .CreateTextFile(strTempFile, True).write strData and show an error as follows -
Run time error ‘5’:
Invalid procedure call or argument.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
No ..Should I check it
After check I closed and reopened my workbook. It still shows an error. This time it is Run-time error '5' --Invalid procedure call or arguement at the same line a.WriteLine(strData)
 
Upvote 0
Upvote 0
I don't have really have anything else to add to this. You may want to get together with the original programmer, and have them take a look at it.
 
Upvote 0
I don't have really have anything else to add to this. You may want to get together with the original programmer, and have them take a look at it.
No Problem Joe. Thanks for being there. As the problem is a unique one, it may take time to solve it. I will find the solution very soon somehow. Thanks once again.
 
Upvote 0
No Problem Joe. Thanks for being there. As the problem is a unique one, it may take time to solve it. I will find the solution very soon somehow. Thanks once again.
You are welcome.

If you do finally figure it out, please post the solution to this thread.
That way, it can help others you may have the same problem (and I am curious about a solution as well).
 
Upvote 0
You are welcome.

If you do finally figure it out, please post the solution to this thread.
That way, it can help others you may have the same problem (and I am curious about a solution as well).
Sure. WIll do that. I am also very curious to know.
 
Upvote 0
Sure. WIll do that. I am also very curious to know.
I did it again from the beginning with a new sheet, creating the whole project. I am able to copy the data manually and paste it in notepad and import the same to tally successfully.But with the code, it runs till the same line and stops as I told you earlier. Nothing is wrong with my sheet nor the codes in the top lines. It has to be wrong in the line where it runs an error. I tried for the last time. I have rephrased my question again and posted in the group. Hope somebody is able to solve this.
 
Upvote 0
Finally found the solution. Thanks to JohnnyL.

You are welcome.

If you do finally figure it out, please post the solution to this thread.
That way, it can help others you may have the same problem (and I am curious about a solution as well).
Joe4. FYI Finally solved the above problem. It was a syntax error in the excel converted from xml. Thanks to JohnnyL who found the problem and helped me with an easier solution too.[/CODE]
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top