Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Compile error on VBA Function

All - I have written a .xla program. Program works great on my machine.
However, when installed another computer, I receive a compile error on the
VBA functions. See below for an example...in example subroutine, the other
computer has a compile error on the LEFT function. On my computer, no issues.

Additional info: Tools | Options | Require Variable Declaration is not
checked on either computer. All variables are defined and option explicit is
set on every module in the .xla.

--------------------------------------------------
Example
--------------------------------------------------
Option Explicit

Sub Test

Dim AnyString as string
Dim MyStr as string
AnyString = "Hello World"
MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function

End Sub

--------------------------------------------------

What do I need to do to the .xla or to the computer in question to get past
this compile issue?

Thank you for any assistance.

MSweetG222

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Compile error on VBA Function

I think for older versions of Excel you need to use Left$. That will work in newer ones as well.
I don't know what subtleties are behind this change.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"MSweetG222" wrote in message ...
| All - I have written a .xla program. Program works great on my machine.
| However, when installed another computer, I receive a compile error on the
| VBA functions. See below for an example...in example subroutine, the other
| computer has a compile error on the LEFT function. On my computer, no issues.
|
| Additional info: Tools | Options | Require Variable Declaration is not
| checked on either computer. All variables are defined and option explicit is
| set on every module in the .xla.
|
| --------------------------------------------------
| Example
| --------------------------------------------------
| Option Explicit
|
| Sub Test
|
| Dim AnyString as string
| Dim MyStr as string
| AnyString = "Hello World"
| MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
|
| End Sub
|
| --------------------------------------------------
|
| What do I need to do to the .xla or to the computer in question to get past
| this compile issue?
|
| Thank you for any assistance.
|
| MSweetG222
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Compile error on VBA Function

Thanks for the reply. Both computers are using 2003. Do you think it still
makes a difference?
--
Thx
MSweetG222



"Niek Otten" wrote:

I think for older versions of Excel you need to use Left$. That will work in newer ones as well.
I don't know what subtleties are behind this change.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"MSweetG222" wrote in message ...
| All - I have written a .xla program. Program works great on my machine.
| However, when installed another computer, I receive a compile error on the
| VBA functions. See below for an example...in example subroutine, the other
| computer has a compile error on the LEFT function. On my computer, no issues.
|
| Additional info: Tools | Options | Require Variable Declaration is not
| checked on either computer. All variables are defined and option explicit is
| set on every module in the .xla.
|
| --------------------------------------------------
| Example
| --------------------------------------------------
| Option Explicit
|
| Sub Test
|
| Dim AnyString as string
| Dim MyStr as string
| AnyString = "Hello World"
| MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
|
| End Sub
|
| --------------------------------------------------
|
| What do I need to do to the .xla or to the computer in question to get past
| this compile issue?
|
| Thank you for any assistance.
|
| MSweetG222
|



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Compile error on VBA Function

No missing DLL references on either machine.
Thanks for the suggestion.
--
Thx
MSweetG222



"Gary Brown" wrote:

On the other machine, get into the VBE.
Check ToolsReferences for a checked reference that stats with 'MISSING'.
Fix the reference.
--
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"MSweetG222" wrote:

All - I have written a .xla program. Program works great on my machine.
However, when installed another computer, I receive a compile error on the
VBA functions. See below for an example...in example subroutine, the other
computer has a compile error on the LEFT function. On my computer, no issues.

Additional info: Tools | Options | Require Variable Declaration is not
checked on either computer. All variables are defined and option explicit is
set on every module in the .xla.

--------------------------------------------------
Example
--------------------------------------------------
Option Explicit

Sub Test

Dim AnyString as string
Dim MyStr as string
AnyString = "Hello World"
MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function

End Sub

--------------------------------------------------

What do I need to do to the .xla or to the computer in question to get past
this compile issue?

Thank you for any assistance.

MSweetG222



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Compile error on VBA Function

This is a common problem. I'd look once more for that missing reference. (It
can't hurt!)

MSweetG222 wrote:

No missing DLL references on either machine.
Thanks for the suggestion.
--
Thx
MSweetG222

"Gary Brown" wrote:

On the other machine, get into the VBE.
Check ToolsReferences for a checked reference that stats with 'MISSING'.
Fix the reference.
--
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"MSweetG222" wrote:

All - I have written a .xla program. Program works great on my machine.
However, when installed another computer, I receive a compile error on the
VBA functions. See below for an example...in example subroutine, the other
computer has a compile error on the LEFT function. On my computer, no issues.

Additional info: Tools | Options | Require Variable Declaration is not
checked on either computer. All variables are defined and option explicit is
set on every module in the .xla.

--------------------------------------------------
Example
--------------------------------------------------
Option Explicit

Sub Test

Dim AnyString as string
Dim MyStr as string
AnyString = "Hello World"
MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function

End Sub

--------------------------------------------------

What do I need to do to the .xla or to the computer in question to get past
this compile issue?

Thank you for any assistance.

MSweetG222


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Compile error on VBA Function

Just to be clear, please check this when the problem add-in is the active
project in the VBE. Click on it in the Project window in the VBE. This is
a classic 'missing reference' problem.

--
Jim
"MSweetG222" wrote in message
...
| No missing DLL references on either machine.
| Thanks for the suggestion.
| --
| Thx
| MSweetG222
|
|
|
| "Gary Brown" wrote:
|
| On the other machine, get into the VBE.
| Check ToolsReferences for a checked reference that stats with
'MISSING'.
| Fix the reference.
| --
| HTH,
| Gary Brown
|
| If this post was helpful to you, please select ''YES'' at the bottom of
the
| post.
|
|
|
| "MSweetG222" wrote:
|
| All - I have written a .xla program. Program works great on my
machine.
| However, when installed another computer, I receive a compile error on
the
| VBA functions. See below for an example...in example subroutine, the
other
| computer has a compile error on the LEFT function. On my computer, no
issues.
|
| Additional info: Tools | Options | Require Variable Declaration is not
| checked on either computer. All variables are defined and option
explicit is
| set on every module in the .xla.
|
| --------------------------------------------------
| Example
| --------------------------------------------------
| Option Explicit
|
| Sub Test
|
| Dim AnyString as string
| Dim MyStr as string
| AnyString = "Hello World"
| MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
|
| End Sub
|
| --------------------------------------------------
|
| What do I need to do to the .xla or to the computer in question to get
past
| this compile issue?
|
| Thank you for any assistance.
|
| MSweetG222
|


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Compile error on VBA Function

Hi Dave,

Is this why I sometimes can't use the Format function? I've been struggling with that one for years! Of course I found
workarounds, but they use worksheet functions which is always less efficient.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


"Dave Peterson" wrote in message ...
| This is a common problem. I'd look once more for that missing reference. (It
| can't hurt!)
|
| MSweetG222 wrote:
|
| No missing DLL references on either machine.
| Thanks for the suggestion.
| --
| Thx
| MSweetG222
|
| "Gary Brown" wrote:
|
| On the other machine, get into the VBE.
| Check ToolsReferences for a checked reference that stats with 'MISSING'.
| Fix the reference.
| --
| HTH,
| Gary Brown
|
| If this post was helpful to you, please select ''YES'' at the bottom of the
| post.
|
|
|
| "MSweetG222" wrote:
|
| All - I have written a .xla program. Program works great on my machine.
| However, when installed another computer, I receive a compile error on the
| VBA functions. See below for an example...in example subroutine, the other
| computer has a compile error on the LEFT function. On my computer, no issues.
|
| Additional info: Tools | Options | Require Variable Declaration is not
| checked on either computer. All variables are defined and option explicit is
| set on every module in the .xla.
|
| --------------------------------------------------
| Example
| --------------------------------------------------
| Option Explicit
|
| Sub Test
|
| Dim AnyString as string
| Dim MyStr as string
| AnyString = "Hello World"
| MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
|
| End Sub
|
| --------------------------------------------------
|
| What do I need to do to the .xla or to the computer in question to get past
| this compile issue?
|
| Thank you for any assistance.
|
| MSweetG222
|
|
| --
|
| Dave Peterson


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Compile error on VBA Function

Is this why I sometimes can't use the Format function?

Really ?

does this work for you -

MsgBox VBA.Strings.Format(Date, "ddd dd mmm yy")

Regards,
Peter T

"Niek Otten" wrote in message
...
Hi Dave,

Is this why I sometimes can't use the Format function? I've been

struggling with that one for years! Of course I found
workarounds, but they use worksheet functions which is always less

efficient.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


"Dave Peterson" wrote in message

...
| This is a common problem. I'd look once more for that missing

reference. (It
| can't hurt!)
|
| MSweetG222 wrote:
|
| No missing DLL references on either machine.
| Thanks for the suggestion.
| --
| Thx
| MSweetG222
|
| "Gary Brown" wrote:
|
| On the other machine, get into the VBE.
| Check ToolsReferences for a checked reference that stats with

'MISSING'.
| Fix the reference.
| --
| HTH,
| Gary Brown
|
| If this post was helpful to you, please select ''YES'' at the bottom

of the
| post.
|
|
|
| "MSweetG222" wrote:
|
| All - I have written a .xla program. Program works great on my

machine.
| However, when installed another computer, I receive a compile

error on the
| VBA functions. See below for an example...in example subroutine,

the other
| computer has a compile error on the LEFT function. On my

computer, no issues.
|
| Additional info: Tools | Options | Require Variable Declaration is

not
| checked on either computer. All variables are defined and option

explicit is
| set on every module in the .xla.
|
| --------------------------------------------------
| Example
| --------------------------------------------------
| Option Explicit
|
| Sub Test
|
| Dim AnyString as string
| Dim MyStr as string
| AnyString = "Hello World"
| MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
|
| End Sub
|
| --------------------------------------------------
|
| What do I need to do to the .xla or to the computer in question to

get past
| this compile issue?
|
| Thank you for any assistance.
|
| MSweetG222
|
|
| --
|
| Dave Peterson




  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Compile error on VBA Function

I can't check right now, because the version I use now does recognize Format.
I'll keep your suggestion for when I encounter this again.

Thanks,

Niek
"Peter T" <peter_t@discussions wrote in message ...
| Is this why I sometimes can't use the Format function?
|
| Really ?
|
| does this work for you -
|
| MsgBox VBA.Strings.Format(Date, "ddd dd mmm yy")
|
| Regards,
| Peter T
|
| "Niek Otten" wrote in message
| ...
| Hi Dave,
|
| Is this why I sometimes can't use the Format function? I've been
| struggling with that one for years! Of course I found
| workarounds, but they use worksheet functions which is always less
| efficient.
|
| --
| Kind regards,
|
| Niek Otten
| Microsoft MVP - Excel
|
|
| "Dave Peterson" wrote in message
| ...
| | This is a common problem. I'd look once more for that missing
| reference. (It
| | can't hurt!)
| |
| | MSweetG222 wrote:
| |
| | No missing DLL references on either machine.
| | Thanks for the suggestion.
| | --
| | Thx
| | MSweetG222
| |
| | "Gary Brown" wrote:
| |
| | On the other machine, get into the VBE.
| | Check ToolsReferences for a checked reference that stats with
| 'MISSING'.
| | Fix the reference.
| | --
| | HTH,
| | Gary Brown
| |
| | If this post was helpful to you, please select ''YES'' at the bottom
| of the
| | post.
| |
| |
| |
| | "MSweetG222" wrote:
| |
| | All - I have written a .xla program. Program works great on my
| machine.
| | However, when installed another computer, I receive a compile
| error on the
| | VBA functions. See below for an example...in example subroutine,
| the other
| | computer has a compile error on the LEFT function. On my
| computer, no issues.
| |
| | Additional info: Tools | Options | Require Variable Declaration is
| not
| | checked on either computer. All variables are defined and option
| explicit is
| | set on every module in the .xla.
| |
| | --------------------------------------------------
| | Example
| | --------------------------------------------------
| | Option Explicit
| |
| | Sub Test
| |
| | Dim AnyString as string
| | Dim MyStr as string
| | AnyString = "Hello World"
| | MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
| |
| | End Sub
| |
| | --------------------------------------------------
| |
| | What do I need to do to the .xla or to the computer in question to
| get past
| | this compile issue?
| |
| | Thank you for any assistance.
| |
| | MSweetG222
| |
| |
| | --
| |
| | Dave Peterson
|
|
|
|




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Compile error on VBA Function

Okay all...She finally got back to me. I made sure she was focused on the
correct VBA project (per Jim's suggestion) and there WAS a missing DLL. :(

Thank you all for your help. :)

Thx
MSweetG222



"Jim Rech" wrote:

Just to be clear, please check this when the problem add-in is the active
project in the VBE. Click on it in the Project window in the VBE. This is
a classic 'missing reference' problem.

--
Jim
"MSweetG222" wrote in message
...
| No missing DLL references on either machine.
| Thanks for the suggestion.
| --
| Thx
| MSweetG222
|
|
|
| "Gary Brown" wrote:
|
| On the other machine, get into the VBE.
| Check ToolsReferences for a checked reference that stats with
'MISSING'.
| Fix the reference.
| --
| HTH,
| Gary Brown
|
| If this post was helpful to you, please select ''YES'' at the bottom of
the
| post.
|
|
|
| "MSweetG222" wrote:
|
| All - I have written a .xla program. Program works great on my
machine.
| However, when installed another computer, I receive a compile error on
the
| VBA functions. See below for an example...in example subroutine, the
other
| computer has a compile error on the LEFT function. On my computer, no
issues.
|
| Additional info: Tools | Options | Require Variable Declaration is not
| checked on either computer. All variables are defined and option
explicit is
| set on every module in the .xla.
|
| --------------------------------------------------
| Example
| --------------------------------------------------
| Option Explicit
|
| Sub Test
|
| Dim AnyString as string
| Dim MyStr as string
| AnyString = "Hello World"
| MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
|
| End Sub
|
| --------------------------------------------------
|
| What do I need to do to the .xla or to the computer in question to get
past
| this compile issue?
|
| Thank you for any assistance.
|
| MSweetG222
|



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Compile error on VBA Function

If you mean that you get a complile error, then I'd guess so.

If you mean that not all the number formats match what you can use with =text(),
then no.

(I'm guessing the first.)


Niek Otten wrote:

Hi Dave,

Is this why I sometimes can't use the Format function? I've been struggling with that one for years! Of course I found
workarounds, but they use worksheet functions which is always less efficient.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Dave Peterson" wrote in message ...
| This is a common problem. I'd look once more for that missing reference. (It
| can't hurt!)
|
| MSweetG222 wrote:
|
| No missing DLL references on either machine.
| Thanks for the suggestion.
| --
| Thx
| MSweetG222
|
| "Gary Brown" wrote:
|
| On the other machine, get into the VBE.
| Check ToolsReferences for a checked reference that stats with 'MISSING'.
| Fix the reference.
| --
| HTH,
| Gary Brown
|
| If this post was helpful to you, please select ''YES'' at the bottom of the
| post.
|
|
|
| "MSweetG222" wrote:
|
| All - I have written a .xla program. Program works great on my machine.
| However, when installed another computer, I receive a compile error on the
| VBA functions. See below for an example...in example subroutine, the other
| computer has a compile error on the LEFT function. On my computer, no issues.
|
| Additional info: Tools | Options | Require Variable Declaration is not
| checked on either computer. All variables are defined and option explicit is
| set on every module in the .xla.
|
| --------------------------------------------------
| Example
| --------------------------------------------------
| Option Explicit
|
| Sub Test
|
| Dim AnyString as string
| Dim MyStr as string
| AnyString = "Hello World"
| MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
|
| End Sub
|
| --------------------------------------------------
|
| What do I need to do to the .xla or to the computer in question to get past
| this compile issue?
|
| Thank you for any assistance.
|
| MSweetG222
|
|
| --
|
| Dave Peterson


--

Dave Peterson
  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Compile error on VBA Function

Can a VBA program be written that tests for missing dlls?
That way I can attach to an Auto_Open and would not have to rely on user
looking into the VBE and reading it to me over the phone.

Thx
MSweetG222



"Jim Rech" wrote:

Just to be clear, please check this when the problem add-in is the active
project in the VBE. Click on it in the Project window in the VBE. This is
a classic 'missing reference' problem.

--
Jim
"MSweetG222" wrote in message
...
| No missing DLL references on either machine.
| Thanks for the suggestion.
| --
| Thx
| MSweetG222
|
|
|
| "Gary Brown" wrote:
|
| On the other machine, get into the VBE.
| Check ToolsReferences for a checked reference that stats with
'MISSING'.
| Fix the reference.
| --
| HTH,
| Gary Brown
|
| If this post was helpful to you, please select ''YES'' at the bottom of
the
| post.
|
|
|
| "MSweetG222" wrote:
|
| All - I have written a .xla program. Program works great on my
machine.
| However, when installed another computer, I receive a compile error on
the
| VBA functions. See below for an example...in example subroutine, the
other
| computer has a compile error on the LEFT function. On my computer, no
issues.
|
| Additional info: Tools | Options | Require Variable Declaration is not
| checked on either computer. All variables are defined and option
explicit is
| set on every module in the .xla.
|
| --------------------------------------------------
| Example
| --------------------------------------------------
| Option Explicit
|
| Sub Test
|
| Dim AnyString as string
| Dim MyStr as string
| AnyString = "Hello World"
| MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
|
| End Sub
|
| --------------------------------------------------
|
| What do I need to do to the .xla or to the computer in question to get
past
| this compile issue?
|
| Thank you for any assistance.
|
| MSweetG222
|



  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Compile error on VBA Function

AFAIK, not in straight forward manner, because as you have found, that
causes code not to run.
If you specify the library of all functions
e.g. VBA.Strings.Left(...)
you don't get the errors that you see, but obviously any calls to missing
libraries will error when they are compiled.

Use of late-binding and CreateObject would be able to tell you if some
instance could be created and deal with the fact if not possible.

NickHK

"MSweetG222" wrote in message
...
Can a VBA program be written that tests for missing dlls?
That way I can attach to an Auto_Open and would not have to rely on user
looking into the VBE and reading it to me over the phone.

Thx
MSweetG222



"Jim Rech" wrote:

Just to be clear, please check this when the problem add-in is the

active
project in the VBE. Click on it in the Project window in the VBE. This

is
a classic 'missing reference' problem.

--
Jim
"MSweetG222" wrote in message
...
| No missing DLL references on either machine.
| Thanks for the suggestion.
| --
| Thx
| MSweetG222
|
|
|
| "Gary Brown" wrote:
|
| On the other machine, get into the VBE.
| Check ToolsReferences for a checked reference that stats with
'MISSING'.
| Fix the reference.
| --
| HTH,
| Gary Brown
|
| If this post was helpful to you, please select ''YES'' at the bottom

of
the
| post.
|
|
|
| "MSweetG222" wrote:
|
| All - I have written a .xla program. Program works great on my
machine.
| However, when installed another computer, I receive a compile

error on
the
| VBA functions. See below for an example...in example subroutine,

the
other
| computer has a compile error on the LEFT function. On my

computer, no
issues.
|
| Additional info: Tools | Options | Require Variable Declaration is

not
| checked on either computer. All variables are defined and option
explicit is
| set on every module in the .xla.
|
| --------------------------------------------------
| Example
| --------------------------------------------------
| Option Explicit
|
| Sub Test
|
| Dim AnyString as string
| Dim MyStr as string
| AnyString = "Hello World"
| MyStr = Left(AnyString, 7) '<<< Compile error on LEFT function
|
| End Sub
|
| --------------------------------------------------
|
| What do I need to do to the .xla or to the computer in question to

get
past
| this compile issue?
|
| Thank you for any assistance.
|
| MSweetG222
|





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
mid function causes a compile error Brotherwarren Excel Programming 3 October 9th 06 06:21 PM
mid function causes a compile error Brotherwarren Excel Programming 1 October 9th 06 06:06 PM
Trying to use INDEX function in VBA Code, compile error Finny[_3_] Excel Programming 14 July 26th 06 07:14 PM
Help With - Compile Error: Sub or Function Not Defined MWS Excel Programming 2 March 23rd 06 06:51 PM
compile error using Left() function Bryce[_3_] Excel Programming 6 December 31st 03 10:01 PM


All times are GMT +1. The time now is 02:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"