Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marceepoo - 17 Jan 2006 06:12 GMT
     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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.