Visual Basic para Aplicaciones - error 7 en tiempo de ejecución: memoria insuficiente

Life is soft - evento anual de software empresarial
 
Vista:
Imágen de perfil de antonio carlos

error 7 en tiempo de ejecución: memoria insuficiente

Publicado por antonio carlos (2 intervenciones) el 08/08/2014 12:22:55
Buenas, estoy intentando elaborar me una base de datos para la cocina manejando recetas, escandallos de platos, etc. y para ello necesito poner fotos de cada receta. Según he leído ha esto se le denomina vincular fotos al formulario. Tengo el código creado en vba pero cuando ejecuto sale un mensaje que pone "error 7 en tiempo de ejecución: memoria insuficiente". Os pego el código conforme lo tengo hasta hora:

Option Compare Database
Option Explicit

Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type


Public Const OFN_READONLY = &H1
Public Const OFN_OVERWRITEPROMPT = &H2
Public Const OFN_HIDEREADONLY = &H4
Public Const OFN_NOCHANGEDIR = &H8
Public Const OFN_SHOWHELP = &H10
Public Const OFN_ENABLEHOOK = &H20
Public Const OFN_ENABLETEMPLATE = &H40
Public Const OFN_ENABLETEMPLATEHANDLE = &H80
Public Const OFN_NOVALIDATE = &H100
Public Const OFN_ALLOWMULTISELECT = &H200
Public Const OFN_EXTENSIONDIFFERENT = &H400
Public Const OFN_PATHMUSTEXIST = &H800
Public Const OFN_FILEMUSTEXIST = &H1000
Public Const OFN_CREATEPROMPT = &H2000
Public Const OFN_SHAREAWARE = &H4000
Public Const OFN_NOREADONLYRETURN = &H8000
Public Const OFN_NOTESTFILECREATE = &H10000
Public Const OFN_NONETWORKBUTTON = &H20000
Public Const OFN_NOLONGNAMES = &H40000
Public Const OFN_EXPLORER = &H80000
Public Const OFN_NODEREFERENCELINKS = &H100000
Public Const OFN_LONGNAMES = &H200000

Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOPENFILENAME As OPENFILENAME) As Long
Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOPENFILENAME As OPENFILENAME) As Long
Declare Function GetFileTitle Lib "comdlg32.dll" Alias "GetFileTitleA" (ByVal lpszFile As String, ByVal lpszTitle As String, ByVal cbBuf As Integer) As Integer
Public Const OFN_SHAREFALLTHROUGH = 2
Public Const OFN_SHARENOWARN = 1
Public Const OFN_SHAREWARN = 0

Function DialogoComun(ObjForm As Form, FiltroArch As String, TipoArch As String, DirectIni As String) As String
Dim file As OPENFILENAME, sFile As String, sFileTitle As String, lResult As Long, iDelim As Integer

file.lStructSize = Len(file)
file.hwndOwner = ObjForm.Hwnd
file.flags = OFN_HIDEREADONLY + OFN_PATHMUSTEXIST + OFN_FILEMUSTEXIST
file.lpstrFile = FiltroArch & String$(250, 0)
file.nMaxFile = 255
file.lpstrFileTitle = String$(255, 0)
file.nMaxFileTitle = 255
'Path Inicial
file.lpstrInitialDir = ObjForm.RutaInicial 'Environ$(DirectIni)
'Filtro
file.lpstrFilter = TipoArch & Chr$(0) & FiltroArch & Chr$(0)
file.nFilterIndex = 1
'Título del diálogo
file.lpstrTitle = "Open"
lResult = GetOpenFileName(file)
If lResult <> 0 Then
iDelim = InStr(file.lpstrFile, Chr$(0)) esta linea aparece en color amarillo, que es donde está el error
If iDelim > 0 Then
sFile = Left$(file.lpstrFile, iDelim - 1)
End If
DialogoComun = sFile
End If

End Function

gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de JuanC

error 7 en tiempo de ejecución: memoria insuficiente

Publicado por JuanC (565 intervenciones) el 08/08/2014 13:13:48
hola Antonio
podrías enviarme o publicar el libro completo?
probé el código y funciona bien...

Saludos, desde Baires, JuanC
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de antonio carlos

error 7 en tiempo de ejecución: memoria insuficiente

Publicado por antonio carlos (2 intervenciones) el 08/08/2014 13:27:21
buenas juanc te enviado el archivo completo de access haber si me puedes echar una mano.
Gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar