Jump to content

VBA open file Has stopped working


ollie

Recommended Posts

Hey folks

 

I wrote a file comparison script for excel (i know this isn't an excel forum) that opens two files as read only. it worked thing when i was demonstrating tot he staff who will be using it but conveniently stopped working while i was showing the manager. can anyone suggest why this may have happened.

 

Combobox1 and 2 were filled using

 

Dim fso As New FileSystemObject       
Dim fld As Folder                    
Dim fil As File   

Set fld = fso.GetFolder("C:\vba excel compare" 

For Each fil In fld.Files           
   ComboBox1.AddItem fil.Name         
   ComboBox2.AddItem fil.Name
next fil

Let Wbook = ComboBox1.Value     'value  "reg 1.xls"
Let Wbook2 = ComboBox2.Value   'value  "reg 2.xls"
Workbooks.Open Filename:=Wbook2, ReadOnly:=True
Workbooks.Open Filename:=Wbook, ReadOnly:=True

i am now getting runtime error 1004

 

Reg 2.xls could not be found. please check the spelling of the file name and make sure the location is correct

 

Any help would be appreciated

 

cheers,

Ollie.

Link to comment
Share on other sites

>>Set fld = fso.GetFolder("C:\vba excel compare"

 

I'd start by adding a trailing parentheses to the above line.

 

then id check to see that the file names are in your comboboxes

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...