Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 3rd, 2010, 11:21 AM
Gavin83's Avatar
Gavin83 Gavin83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 295 Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 8 h 19 m 58 sec
Reputation Power: 45
VBA problem - Ambiguous name detected

Hello everyone,

I've written a macro in word which populates a series of labels on the document and Im running into problems.

It appears to be a problem with the label names rather than a variable name in the code though, and it changes the name of the object. For example, I have a label called lblItem1. Upon entering the document I've noticed it has been renamed to lblItem11 and attempting to change it back results in the ambiguous name detected error. I can't find any other labels on the document named lblItem1 and if I open the properties window on one of the labels and click the dropdown it isn't listed there either. However, if I enter the VBA code window I can see the name lblItem1 in my dropdown.

This is driving me crazy as I can't work out why it's changing the names of my labels and thinking there are already labels present. Any ideas?

If it makes a difference it is a mail merge document and once the macro is run it shuts down the original window and opens a seperate mail merge document.

I'd really appreciate any help or guidance in the right direction.

Reply With Quote
  #2  
Old February 10th, 2010, 05:38 AM
Gavin83's Avatar
Gavin83 Gavin83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 295 Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 8 h 19 m 58 sec
Reputation Power: 45
Is anyone able to help with this? Im happy to give anymore information which may be of use.

Reply With Quote
  #3  
Old February 11th, 2010, 02:41 AM
debasisdas's Avatar
debasisdas debasisdas is offline
Humble Learner
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Location: Bangalore, India
Posts: 279 debasisdas User rank is First Lieutenant (10000 - 20000 Reputation Level)debasisdas User rank is First Lieutenant (10000 - 20000 Reputation Level)debasisdas User rank is First Lieutenant (10000 - 20000 Reputation Level)debasisdas User rank is First Lieutenant (10000 - 20000 Reputation Level)debasisdas User rank is First Lieutenant (10000 - 20000 Reputation Level)debasisdas User rank is First Lieutenant (10000 - 20000 Reputation Level)debasisdas User rank is First Lieutenant (10000 - 20000 Reputation Level)debasisdas User rank is First Lieutenant (10000 - 20000 Reputation Level)  Folding Points: 1142847 Folding Title: Super Ultimate Folder - Level 3Folding Points: 1142847 Folding Title: Super Ultimate Folder - Level 3Folding Points: 1142847 Folding Title: Super Ultimate Folder - Level 3Folding Points: 1142847 Folding Title: Super Ultimate Folder - Level 3Folding Points: 1142847 Folding Title: Super Ultimate Folder - Level 3Folding Points: 1142847 Folding Title: Super Ultimate Folder - Level 3Folding Points: 1142847 Folding Title: Super Ultimate Folder - Level 3Folding Points: 1142847 Folding Title: Super Ultimate Folder - Level 3
Time spent in forums: 2 Months 3 Days 4 h 48 m 5 sec
Reputation Power: 118
Send a message via ICQ to debasisdas Send a message via AIM to debasisdas Send a message via MSN to debasisdas Send a message via Yahoo to debasisdas Send a message via Google Talk to debasisdas Send a message via Skype to debasisdas
I think you have copy and pasted the controls resulting in a control array.

Reply With Quote
  #4  
Old February 13th, 2010, 01:25 PM
BananaRepublic BananaRepublic is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 50 BananaRepublic User rank is Sergeant Major (2000 - 5000 Reputation Level)BananaRepublic User rank is Sergeant Major (2000 - 5000 Reputation Level)BananaRepublic User rank is Sergeant Major (2000 - 5000 Reputation Level)BananaRepublic User rank is Sergeant Major (2000 - 5000 Reputation Level)BananaRepublic User rank is Sergeant Major (2000 - 5000 Reputation Level)BananaRepublic User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 12 h 42 m 56 sec
Reputation Power: 28
It may not be a case of two control having the same name but rather two objects. For example, if your procedure name has same name as the module, that would be an ambiguous name or something like that. So it's not merely a case of looking in the dropdown but also verifying that there is no other name conflict along different objects.

Reply With Quote
  #5  
Old February 18th, 2010, 10:24 AM
Gavin83's Avatar
Gavin83 Gavin83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 295 Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 8 h 19 m 58 sec
Reputation Power: 45
Quote:
Originally Posted by BananaRepublic
It may not be a case of two control having the same name but rather two objects. For example, if your procedure name has same name as the module, that would be an ambiguous name or something like that. So it's not merely a case of looking in the dropdown but also verifying that there is no other name conflict along different objects.


I recreated the template, creating each object seperately, as as to avoid the possibility of a control array and the same thing happened. I also don't have any procedures with the same name. The only point it is mentioned in the code is when I reference the object itself.

I've included the sub routine below:

Code:
    ' Reset captions and heights
    ActiveDocument.lblItem1.Caption = ""
    ActiveDocument.lblCatcode1.Caption = ""
    ActiveDocument.lblQuant1.Caption = ""
    ActiveDocument.lblUnitcost1.Caption = ""
    ActiveDocument.lblDesc1.Caption = ""
            
    ActiveDocument.lblItem1.Height = "14"
    ActiveDocument.lblDesc1.Height = "14"

    Do Until x = rowcount + 1
     
        If x = 1 Then

            ' Populate boxes
            ActiveDocument.lblItem1.Caption = ActiveDocument.MailMerge.DataSource.DataFields("PROV_CCI1ST_1").Value
            ActiveDocument.lblCatcode1.Caption = ActiveDocument.MailMerge.DataSource.DataFields("PROV_CCI2ND_1").Value
            ActiveDocument.lblDesc1.Caption = ActiveDocument.MailMerge.DataSource.DataFields("PROV_CCI3RD_1").Value
            ActiveDocument.lblUnitcost1.Caption = ActiveDocument.MailMerge.DataSource.DataFields("UNIT_COST_1").Value
            ActiveDocument.lblQuant1.Caption = ActiveDocument.MailMerge.DataSource.DataFields("UNIT_QUANT_1").Value

            totalcost = totalcost + (ActiveDocument.MailMerge.DataSource.DataFields("UNIT_COST_1").Value * ActiveDocument.MailMerge.DataSource.DataFields("UNIT_QUANT_1").Value)

            ' Resize label if text will fill it
            If Len(ActiveDocument.MailMerge.DataSource.DataFields("PROV_CCI1ST_1").Value) > 16 Then
            
                ActiveDocument.lblItem1.Height = "28"
              
            End If
            
            If Len(ActiveDocument.MailMerge.DataSource.DataFields("PROV_CCI3RD_1").Value) > 25 Then
            
                ActiveDocument.lblDesc1.Height = "28"
                
            ElseIf Len(ActiveDocument.MailMerge.DataSource.DataFields("PROV_CCI3RD_1").Value) > 50 Then
              
                ActiveDocument.lblDesc1.Height = "45"
                
            Else
            
                ActiveDocument.lblDesc1.Height = "58"
              
            End If
            
        Else

        
           ' STICK SOMETHING IN HERE
        
        
        End If
     
        ' Increase count by 1
        x = x + 1
      
    Loop
    
    ' Set totalcost into totalcost box
    ActiveDocument.lblTotalcost.Caption = "£" + totalcost

Reply With Quote
  #6  
Old March 19th, 2010, 04:22 AM
Gavin83's Avatar
Gavin83 Gavin83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 295 Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 8 h 19 m 58 sec
Reputation Power: 45
Is anyone able to help with this at all? I've been on holiday so I've not had to deal with it but it's still causing me problems and I really can't figure out a solution.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > VBA problem - Ambiguous name detected

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap