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 8579421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:36:18+00:00 2026-06-11T20:36:18+00:00

I have set my sheet up to have a parameters section so users can

  • 0

I have set my sheet up to have a parameters section so users can set-up the sheet and then just update specific areas. Two of the parameters are external files which are “black box” calculation modules.

These are setup with their full paths and stored in a cell on the sheet.

On starting the calculation procedure they get loaded with the following code

 'Set file name and location.
NameOfFile = ActiveWorkbook.Worksheets("Parameters").Cells(8, 2).Value
PathToFile = Left$(NameOfFile, InStrRev(NameOfFile, "\") - 1)
FileNameNoPath = Mid$(NameOfFile, InStrRev(NameOfFile, "\") + 1)
NameOfFile = FileNameNoPath
completefilepath = PathToFile & "\" & NameOfFile
 'set the target workbook to a variable.  If an error is
 'generated, then the workbook is not open, so open it
On Error Resume Next
Set wbTarget = Workbooks(NameOfFile)
  If Err.Number <> 0 Then
     'Open the workbook
    Err.Clear
    Set wbTarget = Workbooks.Open(NameOfFile, UpdateLinks:=False)
    CloseIt = True
End If

 'Check and make sure workbook was opened
If Err.Number = 1004 Then
    MsgBox "Sorry, but the file you specified does not exist!" _
    & vbNewLine & NameOfFile
    Exit Sub
End If

The problem I am having is that when I run the code it says the file is not found. If I go, reset the field in the parameters sheet by reselecting the file (I hae a filedialog set-up to do this), then the code works perfectly and the file opens. Essentially this means that after every time the sheet is shut down, the file has tp be reselcted before the calculations are run. Anyone know what could be causign this?

  • 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-11T20:36:19+00:00Added an answer on June 11, 2026 at 8:36 pm

    In your line of code

    Set wbTarget = Workbooks.Open(NameOfFile, UpdateLinks:=False)
    

    you are specifying file name only, no path. This will try to open the file from the current path, which may not be the intended path. Once you have used the OpenFile dialog and browsed to your file, the Current Path is updated and the code then works.

    You probably meant

    Set wbTarget = Workbooks.Open(completefilepath , UpdateLinks:=False)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set of flat files (114 files) each file is named with database
I have to set lots of triggers in my google spreadsheet to update some
I have a data set in excel sheet which I need to cluster it
I have set up some code so that when two separate buttons are tapped
I have two filestreams which collects different information from different files: FileStream dataStruc =
I have a set od Excel (2003) sheets saved as .xlt format. Now ,how
I have set the eclipse java formatter to wrap lines that exceed 120 characters
I have set a background on the data-role=page element like so <div data-role=page style=background:
I have set up Eclipse Indigo to do line debugging with CFEclipse over port
I have set up upload_max_filesize and post_max_size to 32Mb in php.ini. I am using

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.