How to fix Run/time error 438

S

sebastico

Hello
In this forum Mr. Albert D. Kallal gently helped me with this piece of code
to paste .pdf files on DeskTop

Private SubtxtPath_Click()
Dim strDeskTop As String
'get path location to desktop
strDeskTop = CreateObject("Shell.Application").Namespace(&H10&).self.Path
FileCopy "C:\Belly\DataBase\Docs\" & Me.txtPath, strDeskTop & "\" & Me.txtPath

However, after clicking the button this messaged is displayed: Run-time
error '438':
Object doesn't support this property or method

When I open the vba it shows in yellow colour
FileCopy "C:\Belly\DataBase\Docs\" & Me.txtRuta, strDeskTop & "\" & Me.txtRuta

On the same way, in another forum Mr, Ruiz helped me with another code:

Option Compare Database
Option Explicit
Private Declare Function CopyFile Lib "kernel32.dll" Alias "Copy FileA"
(ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal
bFailIfExists As Long) As Long
Private Sub txtPath_Click()
On Error GoTo error
Dim retval As Long, pru1 As String, pru2 As String
Dim Nfso As Object
Dim Cpta As Object
Dim Arvos As Object
Dim Arvo As Object
Dim PathArvos As String
PathArvos = "C:\Belly\DataBase\Docs\"
Set Nfso = CreateObject("Scripting.FileSystemObject")
Set Cpta = Nfso.getFolder(PathArvos)
Set Arvos = Cpta.Files
For Each Arvo In Arvos
If Me.txtPath = Left(Arvo.Name, InStr(Arvo.Name, ".") - 1) Then
Debug.Print Arvo.Name
pru1 = Arvo
pru2 = "C:\Desktop\" & Arvo.Name '
retval = CopyFile(pru1, pru2, 1)
End If

Next
Set Arvos = Nothing
Set Cpta = Nothing
Set Nfso = Nothing

Sal:
Exit Sub
error:
MsgBox Err.Description
Resume Sal

End Sub

However, vba displays
The expression On Click you entered as the event property setting produced
the following error: Only comments may appear after End Sub, End Function,or
End Property.
Also I have another button with this code
Private Sub Command7_Click()
DoCmd.OpenForm "Pto"
DoCmd.Close acForm, Me.Name
End Sub

I am new to VBA programming and English is not my mother tongue. What does
these errors mean? I have heavily searched the help file and the web and have
not be able to find the answer. I hope I managed to explain my problem well...

Many thanks
 
S

sebastico

Hello

With the second piece of code I already fixed the expression: the following
error: Only comments may appear after End Sub, End Function,or End Property.

Nevertheless, still displays: Object doesn't support this property or method.

I don't know what this errors mean.

!!!Please!!! can someone look through this code and help me to fix this
message Object doesn't support this property or method
 

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