VBA Right function not working in only one workbook

Intertwyne

New Member
Joined
Nov 5, 2015
Messages
1
I have pieced together code from others that when a ‘submit’ button is clicked, is supposed to store a copy of a pdf in the Application.DefaultFilePath.

I have 1 user that the ‘right’ function errors as: “compile error: Can't find project or library”

The error ONLY happens on the workbook I send him, if he opens a new workbook and executes the ‘right’ command in the immediate window, it works.
All other users of the exact same workbook don’t have the problem.

Code:
    If Right(Application.DefaultFilePath, 1) <> "\" Then
        DefPath = Application.DefaultFilePath & "\"
    End If

We are all using the same version of Excel, 2010 and Window 7 Enterprise version 6.1
I have confirmed we have the same library’s checked and in the same order.

Thanks
Terry Reed
 
Last edited by a moderator:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi Terry "Intertwyne",
As you are using similar Versions and have similar Libraries I am puzzled. I can tell you I had a similar problem with a code written in Excel 2013. It worked in 2010 but not 2007.
I found that the problem was that in later versions of XL, functions like Right , Mid Left etc. Went by default to a library that was not available in earlier XL versions.
Range Dimensioning, Range and Value Referencing and Referring to Arrays [SOLVED] - Page 4

The solution to the problem which always worked was to be more explicit, referencing the VBA Library, - so always use

VBA.Left
VBA.Rigtht
VBA.Mid

In place of

Left
Right
Mid

Etc.

Alan
 
Upvote 0

Forum statistics

Threads
1,226,689
Messages
6,192,422
Members
453,723
Latest member
Phil042

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