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
Word Heretic - 17 Jan 2006 08:48 GMT
G'day Marceepoo <36c53a08-2073470544@news.postalias>,
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:
> 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
[quoted text clipped - 43 lines]
> MyPath.PutInClipboard
>End Sub