#1
|
|||
|
|||
Error in macro "Ambiguous name detected" - but why??
Hi,
my issue is pretty simple: In a macro, I have an error message "Ambiguous name detected". I have looked up elsewhere what that message means and it's pretty clear, I'm using something that is already taken so to speak. The VBE also highlights the very word that causes the issue ... <=> but that is a variable?! Aren't variables supposed to be populated and re-populated just as often as you need them to? Can anybody help me there? P.S.: I can of course post the piece of the code where this happens, but it's not quite apparent to me how that would help. Still, if you need to see it, I can provide it. Shortly speaking, I have a variable v_path1 (which is the term highlighted) which holds the filepath and a variable Dateiname which holds the file_name. => Then I have a formula >> v_path_total = v_path1 & "\" & Dateiname << ... and then I open the file like >> Workbooks.Open Filename:=v_path_total, UpdateLinks:=False << That is basically all I'm doing. Thanks a lot! Best regards, Officer_Bierschnitt |
#2
|
||||
|
||||
I'd suggest checking that you haven't declared the variable more than once at any level applicable to your code (i.e. at the procedure-level, module level and/or public module level (check other modules, too)).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Hi,
I have a module of its own called "Declarations" where all I do is declare all of the variables needed in any of the other modules. No variables are declared anywhere else - except the ones that I really need in only one procedure, variables that I need throughout one module are declared in that module, too. I will just try using another variable in the places where that error occurs ... Let's see. P.S.: Now it's happening with another variable, >> v_path_total << - strangely, the error always occurs upon the first mentioning of the variable in a procedure. Can it be that I must not populate the same variable first with one, then with another value (twice or more altogether) in the same procedure? No, actually not, in a subroutine I use one variable and re-populate it with different values four times in a procedure ... I have also just restarted my entire machine, sometimes something gets stuck somewhere and that helps ... but it did not in this case. I'm really at a loss about this. Luckily, I have left the "original" file with the macro intact and I am experimenting on a copy, so it will work on Monday ... |
#4
|
||||
|
||||
Do you use Option Explicit?
If not, and you use a variable above the line that declares it, you would get a "duplicate declaration" error. "Ambiguous name" errors usually occur because you have duplicated a routine name, not a variable. |
#5
|
|||
|
|||
Hmm ... maybe I have it. In addition to the general module "Declarations" that I have, there was one module from which I had copied some code, but which I had not yet removed. There were also some variable_declarations in there, also with PUBLIC, but still, that might have been the issue ...
I just removed it now and it seems to be working. |
#6
|
|||
|
|||
Hi macropod,
I assume you applied this "Solved" button to this thread. You're right, I guess that was the problem. Can I do that myself once I have solved a problem? How? Best regards, Officer_Bierschnitt |
#7
|
||||
|
||||
I may have done, based on your 'it seems to be working' comment.
To mark a thread as solved, select the 'Mark this thread as solved' option from the 'Thread Tools' dropdown.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
|||
|
|||
Ah, I see. Thank you!
That looks a lot more orderly and it does make it easier for everyone to see at a glance which threads still wait for an answer and which don't. I'll look through my own threads now and mark all those as solved where I have found a solution. Thanks! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error: "Changes made were lost...reconnect with server", when switching "from" field | randhurrle | Outlook | 2 | 02-25-2015 06:51 PM |
remove repeated words with " macro " or " wild cards " in texts with parentheses and commas | jocke321 | Word VBA | 2 | 12-10-2014 11:27 AM |
Setup Error "this language is not supported installing office 2007" | Umsotho | Office | 4 | 03-19-2014 03:11 PM |
How to choose a "List" for certain "Heading" from "Modify" tool? | Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |