Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9104795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:56:50+00:00 2026-06-17T01:56:50+00:00

Good evening, I’ve been trying to fix this bug for a few hours now

  • 0

Good evening,

I’ve been trying to fix this bug for a few hours now with no luck. It is especially frustrating since the bug doesn’t express itself on my own work station, but rather on every body else’s.
The purpose of the code is create (FileSystemObject -> CreateTextFile) two .txt-files and write (TextStream) certain information into each of them. The following are the relevant lines of code:

Dim username, filename, filename_2, filepath, complete_filepath, complete_filepath_2 As String
Dim fso As New FileSystemObject
Dim fso_2 As New FileSystemObject
Dim txtStream, txtStream_2 As TextStream

'Gets username
username = CreateObject("WScript.NetWork").username

filename = "db_Redel"
filename_2 = "db_ship"

complete_filepath = "C:\Users\" & username & "\Documents\" & filename & ".txt"
complete_filepath_2 = "C:\Users\" & username & "\Documents\" & filename_2 & ".txt"

Set txtStream = fso.CreateTextFile(complete_filepath, True) 'RUNTIME ERROR 76
Set txtStream_2 = fso_2.CreateTextFile(complete_filepath_2, True)

I am certain the declared filepath exists on the machines this has been tested on. I have a suspicion that something is keeping FileSystemObject object from functioning properly, such as permissions, but I checked the Office security centres on the other work stations and they all had the same settings as me. The following are the activated reference:

  • Visual Basic For Application
  • Microsoft Excel 14.0 Object Library
  • OLE Automation
  • Microsoft Office 14.0 Object Library
  • Microsoft Scripting Runtime

These were also activated on all of the other machines.

What can I do? Just to be clear: The code works as intended on my own work station.

UPDATE: I made one of my friends try it, and it works just fine on his PC too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:56:51+00:00Added an answer on June 17, 2026 at 1:56 am

    Your code ran fine on my PC. However, you are making a common mistake while dimming your variables. The line:

    Dim username, filename, filename_2, filepath, complete_filepath, complete_filepath_2 As String

    Will actually only dim complete_filepath_2 as a string. The others become variant types.

    The same problem with line:

    Dim txtStream, txtStream_2 As TextStream

    Only txtStream_2 will Dim as Textstream

    You need to dim one variable per line:

    Dim username as String

    Dim filename as String

    Dim filename_2 as String

    Dim filepath as String

    Dim complete_filepath as String

    Dim complete_filepath_2 As String

    Only then will you get the variable types you’re expecting

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good evening, I am tired and have been fighting with this for hours. I
Good evening, This is my 1st time on this site, I have been programming
Good evening guys. I'm currently trying to get started on development of a project
Good evening, I'm having an issue with Masonry. This is all my relevant code:
Good evening all, I've been working on an MD5 tool in C# that takes
Good evening! Been searching all over, and I'm afraid I've just got something completely
Good evening, i hope you can help me with this problem, as I'm struggling
Good evening, I am having a weird issue with a method I am trying
Good Evening, I'm building a website which will will look something like this: So
Good Evening (depending on where u are right now). I am a little confused

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.