Re: VBA doesn't recognised mid(..) and left(..)

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Peter Hewett (nospam_at_xtra.co.nz)
Date: 03/14/04


Date: Sun, 14 Mar 2004 23:39:31 +1300

Hi Neil Penn

As Doug said, renaming a Word document or template does not change the way Word
recognises it. Word looks at the binary data contained in a file and not the
file type. When you create a new document based on a document Word propagates
any code contained in the document. The new documents Attached Template will be
the same as its parent document.

You should not need to use explicit references VBA.String.whatever, it looks
like the template/document is corrupt.

Good luck - Peter

"Neil Penn" <neil.penn@btinternet.com>, said:

>
>Thanks for the link below. The explanation given there is to do with a
>missing reference, which doesn't seem to directly explain why renaming a
>document to a template will cause the problem - in the new document created
>fro the template the VBA references do all appear to be set the same as they
>were in the original .DOC document.
>
>I found that if I added in full references to the functions - for example
>VBA.String.Mid(..) or VBA.String.Left(..) then it worked ok.
>
>I would conclude that using rename to create a template must create a
>problem with the references for the VBA project.
>
>Thanks for your help.
>
>"Peter Hewett" <nospam@xtra.co.nz> wrote in message
>news:dr1250dti4t8gmf8bkiv8ba8n2grtnbk5i@4ax.com...
>> Hi Neil Penn
>>
>> Check out the following link:
>>
>> Undefined Variable: Mid, Left, Right not working
>> http://word.mvps.org/faqs/apperrors/MidNotWorking.htm
>>
>> HTH + Cheers - Peter
>>
>>
>> "Neil Penn" <neil.penn@btinternet.com>, said:
>>
>> >Word 2000
>> >Windows 2000
>> >
>> >This is really weird.
>> >
>> >This evening I wrote a VBA macro to go to a database to bring back data
>and
>> >replace some values in a Word document.
>> >
>> >I developed the macro in a .DOC until it all ran ok, then renamed the
>> >document to a .DOT for final use.
>> >
>> >When I went to test the .DOT things went very strange. First none of the
>> >enumerations or constants were being recognised - for example adStateOpen
>> >for ADO wasn't recognised and the Microsoft Scripting constant for
>opening a
>> >text file for reading wasn't recognised either. OK - I just wrote local
>> >variables to re-define the constants to get around that problem. What
>really
>> >through me was when VBA said it didn't recognised mid(..) and left(..)
>> >functions. At this point I went home.
>> >
>> >I am hoping that when I get in tomorrow a reboot will sort everything
>out,
>> >but if not can anyone think what has caused the problem?
>> >
>> >I should add that the references are still all in the project. If I hit
>F2 I
>> >can find all the references it says it doesn't recognise.
>> >
>> >I really need it to run as a .DOT as the code runs about replacing
>> >placeholders with database data so I don't want to change the original
>> >document.
>> >
>>
>

HTH + Cheers - Peter



Relevant Pages

  • Re: View breaks
    ... Thanks Beth, that seems like a possible solution. ... References using a borderless one row, ... MVP FAQ site: http://mvps.org/ ... update function which makes for creating a global template pretty near ...
    (microsoft.public.word.pagelayout)
  • Re: Newer version of Word cant use references to older libraries
    ... One thing I can say is that references don't go backwards very well. ... Word template that used objects from a VB6 project. ... I had to switch my VB6 project to late binding ... You might want to rebuild your template from scratch. ...
    (microsoft.public.word.vba.general)
  • Re: View breaks
    ... References using a borderless one row, ... Microsoft Office MVP ... MVP FAQ site: http://mvps.org/ ... update function which makes for creating a global template pretty near ...
    (microsoft.public.word.pagelayout)
  • Re: VS Enterprise Template: Auto Cross Project Reference
    ... I've created an Enterprise Template for projects for our system ... UIController project) when creating the template. ... project references are already set (my UI project references my UIController ... My IDE is getting confused because the added Business Entity ...
    (microsoft.public.vsnet.enterprise.tools)
  • Re: View breaks
    ... Thanks for your response Beth. ... reluctant for a few reasons. ... update function which makes for creating a global template pretty near ... is to put references to some procedures, ...
    (microsoft.public.word.pagelayout)