Can't find project or library, if my userform calls the macro

M

Marceepoo

I have a command button on a userform, and the button triggers the code
shown below [in the macro Private Sub btnPath_Click()], which works just
fine.
But I would like to remove most of the code from the form and instead
use the identical code, which I copied into my newmacros module, in a macro
(shown below) named: DocPath
I un-commented the line: 'Call DocPath [in the form's macro Private Sub
btnPath_Click()], , and I removed the rest of the code from Private Sub
btnPath_Click(), except for the line: End Sub
Now I get the error message: Compile Error: Can't find project or
library, and
the word "left" is highlighted in the macro DocPath.
Does anyone know why moving the code from the form to the NewMacros
module prevents vba from finding the project or library it needs?
Thanks for your help.
marceepoo


Private Sub btnPath_Click()
' Copy path to strVar and then to clipboard
' Macro recorded 8/22/2004 by Marc B. Hankin
'
frmMenuGnlAccess.Hide
'Call DocPath
Dim strFulNam As String, strPath As String
Dim lLenLFileNam As Long
Dim MyPath As DataObject
Set MyPath = New DataObject
strFulNam = ActiveDocument.FullName
lLenLFileNam = InStrRev(strFulNam, "\")
strPath = Left(strFulNam, lLenLFileNam)
MsgBox strFulNam & vbCrLf & strPath
MyPath.SetText strPath
MyPath.PutInClipboard
End Sub


Sub DocPath()
Dim strFulNam As String, strPath As String
Dim lLenLFileNam As Long
Dim MyPath As DataObject
Set MyPath = New DataObject
strFulNam = ActiveDocument.FullName
lLenLFileNam = InStrRev(strFulNam, "\")
strPath = Left(strFulNam, lLenLFileNam)
MsgBox strFulNam & vbCrLf & strPath
MyPath.SetText strPath
MyPath.PutInClipboard
End Sub
 
W

Word Heretic

G'day Marceepoo <[email protected]>,

Strange fer sure. However, try changing the untyped functions to typed
ones, just in case it jiggles whatever loose for you.

eg change Left( to Left$(


Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Marceepoo reckoned:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top