VB 'Retained ist ein ungültiger Schlüssel

Hallo Wissende,

auf http://www.xlam.ch/xlimits/downloads.htm ,
(dort mit Strg+F nach „DSOFile.exe“ suchen)
kann man sich die DSOFile.exe herunterladen.

Nach Starten der Exe hat man eine DSOFile.dll und in einem Unterverzeichnis VB-Dateien (frm,frx,log,vbp,vbw).

Laut Beschreibung auf der o.g. Webseite kann man mittels dieser dll auf die Dokumenteigenschaften von Office-Dateien(xls,doc) zugreifen.
Und dies mit VB und VBA. Als Beispiel wie das geht sind die VB-Dateien gedacht.

Ich habe VB5.0 installiert. Dort habe ich unter projekt–Verweise einen Verweis auf die dll gesetzt. Dann versucht die vbp zu öffnen.
Leider kommt sofort die im Betreff genannte Fehlermeldung samt dem Hinweis daß die vbp deshalb nicht geladen werden konnte:frowning:

Da die Tatsache daß ich VB5.0 installiert keinesfalls bedeutet daß ich auch nur irgendwas in VB weiß, so weiß ich jetzt nicht weiter :smile:)

Wie in **/t/frage-zu-customdocumentproperties/4648096/4

Da der Codeentwickler netterweise sprechende Präfixe für die Variablennamen benutzt hat habe ich ein vages Bild wie denn die Form bestückt ist und habe versucht dies in einer Vba-Userform nachzustellen.

D.h. aus den Codezeilen:

txtCustName.Text = „“
txtCustValue.Text = „“
lstCustType.ListIndex = 0

schloß ich daß ich dafür 2 Textboxen und eine ListBox brauche usw.
Das klappte leidlich gut, allerdings bin ich mir bei den Namen „imgIcon“ und „picPreview“ nicht ganz sicher ob es beides Bilder sind oder vielleicht doch unterschiedliche Steuerelemente.

Nachstehend ist der von mir umgesetzte Vba-Code.
Naja, ist noch eine Riesenbaustelle, die meisten Felder der Userform bleiben noch leer.
Immerhin sieht man in der ComboBox schon die Dokumenteigenschaften :smile:

Jetzt bräuchte ich halt eine funktionierende VB-Exe oder viel besser Hinweise wie ich den VB-Code zum Laufen bringe, damit ich überhaupt mal sehe wie die Form eigentlich aussieht um das nachzustellen.

Danke ^ Gruß
Reinhard

Option Explicit

'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
' FileProp Form Member Variables
'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
Private oFilePropReader As DSOleFile.PropertyReader
Private oDocProp As DSOleFile.DocumentProperties

Private Sub UserForm\_Initialize()

' Create an instance of the reader class (if this errors,
' the DLL was not registered with REGSVR32.EXE)...
Set oFilePropReader = New DSOleFile.PropertyReader

' If you plan to be working with localized documents (non-English)
' you can set this property to make sure new property sets are
' created in Unicode instead of ANSI.
'
' oFilePropReader.UseUnicodePropSets = True
'
' Office documents made with US/UK English versions of Office save
' string values in ANSI, and have had reported problems reading values
' that weren't, so for compatiblity the reader defaults to ANSI.

' Pick a file and open the properties for it, If user cancels, we exit...
If Not OpenDocumentProperties Then End

End Sub

Private Sub UserForm\_Terminate()
' Save any changes before we unload...
UpdateSummaryInfo
Set oDocProp = Nothing
Set oFilePropReader = Nothing
End Sub
Private Sub CommandButton1\_Click()
UpdateSummaryInfo
OpenDocumentProperties

End Sub

Private Sub cmdOpenFile\_Click()
UpdateSummaryInfo
OpenDocumentProperties
End Sub

Private Sub checkbox1\_Click()
' The preview is loaded in a picture box. When this item is
' checked, move the picture box on screen. Otherwise, move off..
If CheckBox1.Value Then
 ListBox1.Left = -20000
 Image2.Left = 1140
Else
 Image2.Left = -20000
 ListBox1.Left = 1140
End If
End Sub

'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
' OpenDocumentProperties -- Fills the dialog with properties
' from a user supplied Office document.
'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
Public Function OpenDocumentProperties() As Boolean
Dim oCustProp As DSOleFile.CustomProperty
Dim sFile As String, sTmp As String

GetFileFromUser:
'On error GoTo Err\_Trap

' Ask the user for an OLE Structure Storage file to read
' the document properties from...
With CommonDialog1
 .Flags = cdlOFNHideReadOnly Or cdlOFNFileMustExist
 .Filter = "Office Files|\*.doc;\*.xls;\*.ppt|All Files|\*.\*"
 .Filename = ""
 .ShowOpen
 sFile = .Filename
End With
' If the user cancels the dialog, exit out.
If Len(sFile) = 0 Then Exit Function

' Here is where we load the document properties for the file
' selected. The function will return a DocumentProperties object.
' We must have exclusive access to the storage of the file. If
' another app has the file open, this function will raise an error
Set oDocProp = oFilePropReader.GetDocumentProperties(sFile)

'On error Resume Next
' Read in some of the most common properties...
'lbName.Caption = oDocProp.Name
'lbAppName.Caption = oDocProp.AppName
Label1.Caption = oDocProp.Name
Label2.Caption = oDocProp.AppName

' This gets the associated icon picture for the file type...
'Set imgIcon.Picture = oDocProp.Icon
Set Image1.Picture = oDocProp.Icon
' The standard document properties are loaded into text boxes,
' and can be changed in this sample. Other properties can be changed
' as well, but these are the only ones we demonstrate here...
TextBox3.Text = oDocProp.Title
TextBox1.Text = oDocProp.Author
TextBox2.Text = oDocProp.Comments

' Fill in the Summary/Statistics information in the Normal
' properties list. These properties are standard Summay and Document
' Properties in OLE...
ListBox1.Clear
ListBox1.AddItem "Subject: " & oDocProp.Subject
ListBox1.AddItem "Category: " & oDocProp.Category
ListBox1.AddItem "Company: " & oDocProp.Company
ListBox1.AddItem "Manager: " & oDocProp.Manager
ListBox1.AddItem "CLSID: " & oDocProp.CLSID
ListBox1.AddItem "ProgID: " & oDocProp.ProgId
ListBox1.AddItem "Word Count: " & oDocProp.WordCount
ListBox1.AddItem "Page Count: " & oDocProp.PageCount
ListBox1.AddItem "Paragraph Count: " & oDocProp.ParagraphCount
ListBox1.AddItem "Line Count: " & oDocProp.LineCount
ListBox1.AddItem "Character Count: " & oDocProp.CharacterCount
ListBox1.AddItem "Character Count (w/spaces): " & oDocProp.CharacterCountWithSpaces
ListBox1.AddItem "Byte Count: " & oDocProp.ByteCount
ListBox1.AddItem "Slide Count: " & oDocProp.SlideCount
ListBox1.AddItem "Note Count: " & oDocProp.PresentationNotes
ListBox1.AddItem "Hidden Slides: " & oDocProp.HiddenSlides
ListBox1.AddItem "MultimediaClips: " & oDocProp.MultimediaClips
ListBox1.AddItem "Last Edited by: " & oDocProp.LastEditedBy
ListBox1.AddItem "Date Created: " & oDocProp.DateCreated
ListBox1.AddItem "Date Last Printed: " & oDocProp.DateLastPrinted
ListBox1.AddItem "Date Last Saved: " & oDocProp.DateLastSaved
ListBox1.AddItem "Total Editing Time (mins): " & oDocProp.TotalEditTime
ListBox1.AddItem "Version: " & oDocProp.Version
ListBox1.AddItem "Revision Number: " & oDocProp.RevisionNumber
ListBox1.AddItem "Template Name: " & oDocProp.Template
ListBox1.AddItem "Presentation Format: " & oDocProp.PresentationFormat

On Error Resume Next
' The HasMacros property only works for Excel & Word files
' and raises error if document is not one of these. Ignore
' any error for this sample.
Dim sItem As String
sItem = CStr(oDocProp.HasMacros)
If Err Then sItem = ""
ListBox1.AddItem "Macros Attached: " & sItem

' We'll get the thumnail image of the document (if available)...
Dim oPicDisp As StdPicture
Set oPicDisp = oDocProp.Thumbnail
If oPicDisp Is Nothing Then
 CheckBox1.Enabled = False
Else
 Set Image2.Picture = oPicDisp
 CheckBox1.Enabled = True
End If

''On error GoTo Err\_Trap

TextBox6.Text = ""
TextBox7.Text = ""
ListBox2.ListIndex = 0

' Loop through the custom properties collection and
' add each item to a list box...
ListBox3.Clear
For Each oCustProp In oDocProp.CustomProperties
 sTmp = oCustProp.Name & ": " & CStr(oCustProp.Value)
 sTmp = sTmp & " [" & CustTypeName(oCustProp.Type) & "]"
 ListBox3.AddItem sTmp
Next

' Disable items if file is read only...
Call EnableItems((Not oDocProp.IsReadOnly))

' The operation was successful.
OpenDocumentProperties = True
Exit Function

Err\_Trap:
' Trap comm'On errors returned from componenet...
Select Case Err.Number
 Case &H80040203
 ' The file is open by another program
 MsgBox Err.Description & " Please choose another file."
 Err.Clear: Resume GetFileFromUser
 Case &H80040202
 ' The file selected is not an OLE structured storage file
 MsgBox Err.Description & " Please choose another file."
 Err.Clear: Resume GetFileFromUser
 Case &H80040201
 ' DCOM is not installed -- fall through to MsgBox below
End Select

MsgBox "Error: " & Err.Description, vbCritical, "Err: " & CStr(Err.Number)
End Function

'

'Private Sub UpdateSummaryInfo()
' ' Quick and dirty save routine...
' 'On error Resume Next
' If textbox1.Text oDocProp.Author Then
' oDocProp.Author = textbox1.Text
' End If
' If textbox2.Text oDocProp.Comments Then
' oDocProp.Comments = textbox2.Text
' End If
' If textbox3.Text oDocProp.Title Then
' oDocProp.Title = textbox3.Text
' End If
'End Sub


Private Sub UpdateSummaryInfo()
' Quick and dirty save routine...
'On Error Resume Next
If TextBox1.Text oDocProp.Author Then
 oDocProp.Author = TextBox1.Text
End If
If TextBox2.Text oDocProp.Comments Then
 oDocProp.Comments = TextBox2.Text
End If
If TextBox3.Text oDocProp.Title Then
 oDocProp.Title = TextBox3.Text
End If
End Sub








'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
' Add & Remove custom properties to the open file.
'\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
Private Sub commandbutton2\_Click()
Dim sName As String, sTmp As String
Dim sValueText As String
Dim vValue As Variant
Dim lType As Long

'On error Resume Next
sName = TextBox6.Text
sValueText = TextBox7.Text

' We can't add a custom property unless we have a
' valid name and value.
If ((sName = "") Or (sValueText = "")) Then Exit Sub

' Convert the Text string to a VARIANT of the type
' specified in the drop down list.
lType = ListBox2.ListIndex + 1
Select Case lType
 Case 2
 vValue = CLng(sValueText)
 Case 3
 vValue = CDbl(sValueText)
 Case 4
 vValue = CBool(sValueText)
 Case 5
 vValue = CDate(sValueText)
 Case Else
 vValue = sValueText
End Select

' Add the property...
oDocProp.CustomProperties.Add sName, vValue
If Err Then
 ' If an error occurs, it's most likely because the
 ' the property name already exists...
 MsgBox "The item could not be added:" & vbCrLf & Err.Description
 Err.Clear
Else
 ' Add item to our list box...
 sTmp = sName & ": " & CStr(vValue) & " ["
 sTmp = sTmp & CustTypeName(lType) & "]"
 ListBox3.AddItem sTmp

 TextBox6.Text = ""
 TextBox7.Text = ""
End If

End Sub

Private Sub cmdCustRemove\_Click()
Dim oRmProp As DSOleFile.CustomProperty
Dim sName As String, sTmp As String

'On error Resume Next
sTmp = ListBox3.List(ListBox3.ListIndex)
sName = Left(sTmp, InStr(sTmp, ":") - 1)

' Set a reference to the custom property we want and
' then call remove...
Set oRmProp = oDocProp.CustomProperties.Item(sName)
oRmProp.Remove
Set oRmProp = Nothing

ListBox3.RemoveItem ListBox3.ListIndex
'cmdCustRemove.Enabled = False
End Sub

Private Sub listbox3\_GotFocus()
'If ListBox3.ListCount 0 Then cmdCustRemove.Enabled = True
End Sub

Private Function CustTypeName(lType As Long) As String
' This function simply maps string names to the
' VARIANT type of a custom property.
Select Case lType
 Case 1
 CustTypeName = "String"
 Case 2
 CustTypeName = "Long"
 Case 3
 CustTypeName = "Double"
 Case 4
 CustTypeName = "Boolean"
 Case 5
 CustTypeName = "Date"
 Case Else
 CustTypeName = "Unknown"
End Select
End Function

Private Sub EnableItems(bEnable As Boolean)
TextBox3.Enabled = bEnable
TextBox1.Enabled = bEnable
TextBox2.Enabled = bEnable
TextBox6.Enabled = bEnable
TextBox7.Enabled = bEnable
ListBox2.Enabled = bEnable
ListBox3.Enabled = bEnable
CommandButton2.Enabled = bEnable
End Sub





'Option Explicit
'
''\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
'' FileProp Form Member Variables
''\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
'Private oFilePropReader As DSOleFile.PropertyReader
'Private oDocProp As DSOleFile.DocumentProperties
'
'Private Sub Form\_Load()
'
' ' Create an instance of the reader class (if this errors,
' ' the DLL was not registered with REGSVR32.EXE)...
' Set oFilePropReader = New DSOleFile.PropertyReader
'
' ' If you plan to be working with localized documents (non-English)
' ' you can set this property to make sure new property sets are
' ' created in Unicode instead of ANSI.
' '
' ' oFilePropReader.UseUnicodePropSets = True
' '
' ' Office documents made with US/UK English versions of Office save
' ' string values in ANSI, and have had reported problems reading values
' ' that weren't, so for compatiblity the reader defaults to ANSI.
'
' ' Pick a file and open the properties for it, If user cancels, we exit...
' If Not OpenDocumentProperties Then End
'
'End Sub
'
'Private Sub Form\_Unload(Cancel As Integer)
' ' Save any changes before we unload...
' UpdateSummaryInfo
' Set oDocProp = Nothing
' Set oFilePropReader = Nothing
'End Sub
'Private Sub CommandButton1\_Click()
' UpdateSummaryInfo
' OpenDocumentProperties
'
'End Sub
'
'Private Sub cmdOpenFile\_Click()
' UpdateSummaryInfo
' OpenDocumentProperties
'End Sub
'
'Private Sub checkbox1\_Click()
' ' The preview is loaded in a picture box. When this item is
' ' checked, move the picture box on screen. Otherwise, move off..
' If CheckBox1.Value Then
' ListBox1.Left = -20000
' Image2.Left = 1140
' Else
' Image2.Left = -20000
' ListBox1.Left = 1140
' End If
'End Sub
'
''\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
'' OpenDocumentProperties -- Fills the dialog with properties
'' from a user supplied Office document.
''\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
'Public Function OpenDocumentProperties() As Boolean
' Dim oCustProp As DSOleFile.CustomProperty
' Dim sFile As String, sTmp As String
'
'GetFileFromUser:
' 'On error GoTo Err\_Trap
'
' ' Ask the user for an OLE Structure Storage file to read
' ' the document properties from...
' With CommonDialog1
' .Flags = cdlOFNHideReadOnly Or cdlOFNFileMustExist
' .Filter = "Office Files|\*.doc;\*.xls;\*.ppt|All Files|\*.\*"
' .Filename = ""
' .ShowOpen
' sFile = .Filename
' End With
' ' If the user cancels the dialog, exit out.
' If Len(sFile) = 0 Then Exit Function
'
' ' Here is where we load the document properties for the file
' ' selected. The function will return a DocumentProperties object.
' ' We must have exclusive access to the storage of the file. If
' ' another app has the file open, this function will raise an error
' Set oDocProp = oFilePropReader.GetDocumentProperties(sFile)
'
' 'On error Resume Next
' ' Read in some of the most common properties...
' 'lbName.Caption = oDocProp.Name
' 'lbAppName.Caption = oDocProp.AppName
' Label1.Caption = oDocProp.Name
' Label2.Caption = oDocProp.AppName
'
' ' This gets the associated icon picture for the file type...
' 'Set imgIcon.Picture = oDocProp.Icon
' Set Image1.Picture = oDocProp.Icon
' ' The standard document properties are loaded into text boxes,
' ' and can be changed in this sample. Other properties can be changed
' ' as well, but these are the only ones we demonstrate here...
' TextBox3.Text = oDocProp.Title
' TextBox1.Text = oDocProp.Author
' TextBox2.Text = oDocProp.Comments
'
' ' Fill in the Summary/Statistics information in the Normal
' ' properties list. These properties are standard Summay and Document
' ' Properties in OLE...
' ListBox1.Clear
' ListBox1.AddItem "Subject: " & oDocProp.Subject
' ListBox1.AddItem "Category: " & oDocProp.Category
' ListBox1.AddItem "Company: " & oDocProp.Company
' ListBox1.AddItem "Manager: " & oDocProp.Manager
' ListBox1.AddItem "CLSID: " & oDocProp.CLSID
' ListBox1.AddItem "ProgID: " & oDocProp.ProgId
' ListBox1.AddItem "Word Count: " & oDocProp.WordCount
' ListBox1.AddItem "Page Count: " & oDocProp.PageCount
' ListBox1.AddItem "Paragraph Count: " & oDocProp.ParagraphCount
' ListBox1.AddItem "Line Count: " & oDocProp.LineCount
' ListBox1.AddItem "Character Count: " & oDocProp.CharacterCount
' ListBox1.AddItem "Character Count (w/spaces): " & oDocProp.CharacterCountWithSpaces
' ListBox1.AddItem "Byte Count: " & oDocProp.ByteCount
' ListBox1.AddItem "Slide Count: " & oDocProp.SlideCount
' ListBox1.AddItem "Note Count: " & oDocProp.PresentationNotes
' ListBox1.AddItem "Hidden Slides: " & oDocProp.HiddenSlides
' ListBox1.AddItem "MultimediaClips: " & oDocProp.MultimediaClips
' ListBox1.AddItem "Last Edited by: " & oDocProp.LastEditedBy
' ListBox1.AddItem "Date Created: " & oDocProp.DateCreated
' ListBox1.AddItem "Date Last Printed: " & oDocProp.DateLastPrinted
' ListBox1.AddItem "Date Last Saved: " & oDocProp.DateLastSaved
' ListBox1.AddItem "Total Editing Time (mins): " & oDocProp.TotalEditTime
' ListBox1.AddItem "Version: " & oDocProp.Version
' ListBox1.AddItem "Revision Number: " & oDocProp.RevisionNumber
' ListBox1.AddItem "Template Name: " & oDocProp.Template
' ListBox1.AddItem "Presentation Format: " & oDocProp.PresentationFormat
'
' 'On error Resume Next
' ' The HasMacros property only works for Excel & Word files
' ' and raises error if document is not one of these. Ignore
' ' any error for this sample.
' Dim sItem As String
' sItem = CStr(oDocProp.HasMacros)
' If Err Then sItem = ""
' ListBox1.AddItem "Macros Attached: " & sItem
'
'' We'll get the thumnail image of the document (if available)...
' Dim oPicDisp As StdPicture
' Set oPicDisp = oDocProp.Thumbnail
' If oPicDisp Is Nothing Then
' CheckBox1.Enabled = False
' Else
' Set Image2.Picture = oPicDisp
' CheckBox1.Enabled = True
' End If
'
' ''On error GoTo Err\_Trap
'
' TextBox6.Text = ""
' TextBox7.Text = ""
' ListBox2.ListIndex = 0
'
' ' Loop through the custom properties collection and
' ' add each item to a list box...
' ListBox3.Clear
' For Each oCustProp In oDocProp.CustomProperties
' sTmp = oCustProp.Name & ": " & CStr(oCustProp.Value)
' sTmp = sTmp & " [" & CustTypeName(oCustProp.Type) & "]"
' ListBox3.AddItem sTmp
' Next
'
' ' Disable items if file is read only...
' Call EnableItems((Not oDocProp.IsReadOnly))
'
' ' The operation was successful.
' OpenDocumentProperties = True
'Exit Function
'
'Err\_Trap:
' ' Trap comm'On errors returned from componenet...
' Select Case Err.Number
' Case &H80040203
' ' The file is open by another program
' MsgBox Err.Description & " Please choose another file."
' Err.Clear: Resume GetFileFromUser
' Case &H80040202
' ' The file selected is not an OLE structured storage file
' MsgBox Err.Description & " Please choose another file."
' Err.Clear: Resume GetFileFromUser
' Case &H80040201
' ' DCOM is not installed -- fall through to MsgBox below
' End Select
'
' MsgBox "Error: " & Err.Description, vbCritical, "Err: " & CStr(Err.Number)
'End Function
'
''Private Sub UpdateSummaryInfo()
'' ' Quick and dirty save routine...
'' 'On error Resume Next
'' If textbox1.Text oDocProp.Author Then
'' oDocProp.Author = textbox1.Text
'' End If
'' If textbox2.Text oDocProp.Comments Then
'' oDocProp.Comments = textbox2.Text
'' End If
'' If textbox3.Text oDocProp.Title Then
'' oDocProp.Title = textbox3.Text
'' End If
''End Sub
'Private Sub UpdateSummaryInfo()
' ' Quick and dirty save routine...
' 'On Error Resume Next
' If TextBox1.Text oDocProp.Author Then
' oDocProp.Author = TextBox1.Text
' End If
' If TextBox2.Text oDocProp.Comments Then
' oDocProp.Comments = TextBox2.Text
' End If
' If TextBox3.Text oDocProp.Title Then
' oDocProp.Title = TextBox3.Text
' End If
'End Sub
'
'
'
'
'
'
'
'
''\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
'' Add & Remove custom properties to the open file.
''\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
'Private Sub commandbutton2\_Click()
' Dim sName As String, sTmp As String
' Dim sValueText As String
' Dim vValue As Variant
' Dim lType As Long
'
' 'On error Resume Next
' sName = TextBox6.Text
' sValueText = TextBox7.Text
'
' ' We can't add a custom property unless we have a
' ' valid name and value.
' If ((sName = "") Or (sValueText = "")) Then Exit Sub
'
' ' Convert the Text string to a VARIANT of the type
' ' specified in the drop down list.
' lType = ListBox2.ListIndex + 1
' Select Case lType
' Case 2
' vValue = CLng(sValueText)
' Case 3
' vValue = CDbl(sValueText)
' Case 4
' vValue = CBool(sValueText)
' Case 5
' vValue = CDate(sValueText)
' Case Else
' vValue = sValueText
' End Select
'
' ' Add the property...
' oDocProp.CustomProperties.Add sName, vValue
' If Err Then
' ' If an error occurs, it's most likely because the
' ' the property name already exists...
' MsgBox "The item could not be added:" & vbCrLf & Err.Description
' Err.Clear
' Else
' ' Add item to our list box...
' sTmp = sName & ": " & CStr(vValue) & " ["
' sTmp = sTmp & CustTypeName(lType) & "]"
' ListBox3.AddItem sTmp
'
' TextBox6.Text = ""
' TextBox7.Text = ""
' End If
'
'End Sub
'
'Private Sub cmdCustRemove\_Click()
' Dim oRmProp As DSOleFile.CustomProperty
' Dim sName As String, sTmp As String
'
' 'On error Resume Next
' sTmp = ListBox3.List(ListBox3.ListIndex)
' sName = Left(sTmp, InStr(sTmp, ":") - 1)
'
' ' Set a reference to the custom property we want and
' ' then call remove...
' Set oRmProp = oDocProp.CustomProperties.Item(sName)
' oRmProp.Remove
' Set oRmProp = Nothing
'
' ListBox3.RemoveItem ListBox3.ListIndex
' cmdCustRemove.Enabled = False
'End Sub
'
'Private Sub listbox3\_GotFocus()
' If ListBox3.ListCount 0 Then cmdCustRemove.Enabled = True
'End Sub
'
'Private Function CustTypeName(lType As Long) As String
' ' This function simply maps string names to the
' ' VARIANT type of a custom property.
' Select Case lType
' Case 1
' CustTypeName = "String"
' Case 2
' CustTypeName = "Long"
' Case 3
' CustTypeName = "Double"
' Case 4
' CustTypeName = "Boolean"
' Case 5
' CustTypeName = "Date"
' Case Else
' CustTypeName = "Unknown"
' End Select
'End Function
'
'Private Sub EnableItems(bEnable As Boolean)
' TextBox3.Enabled = bEnable
' TextBox1.Enabled = bEnable
' TextBox2.Enabled = bEnable
' TextBox6.Enabled = bEnable
' TextBox7.Enabled = bEnable
' ListBox2.Enabled = bEnable
' ListBox3.Enabled = bEnable
' CommandButton2.Enabled = bEnable
'End Sub
'
'
'
'Private Sub UserForm\_Click()
'
'End Sub**  

Hallo,

in der „propdemo.vbp“ stand der Eintrag
Retained=0
den habe ich ersatzlos gestrichen.
Dann wurde noch ein Schlüssel bemängelt, den habe ich auch rausgeworfen (Namen leider vergessen)
Dann noch den verweis auf Comdlg32.oxc eingebaut weil danach verlangt wurde.

Jetzt kann ich im Editor die propdemo.vbp öffnen. Nur, danach tut sich nix. Drücke ich auf F5 so kommt die Fehlermeldung:

Startformular oder Sub main() erforderlich.

Das sehe ich genauso, denn von Code ist nirgends was zu sehen.
Bei Ansicht sind die obersten 4 Punkte deaktiviert.

Bestätige ich die Fehlermeldung mit Ok oder schließe sie mit dem Schließkreuz kommt die Fehlermeldung

Nicht genügend Speicher

Im Projekt Explorer Fenster steht zwar der name der vbp, aber mehr auch nicht.

Danke ^ Gruß
Reinhard

Hallo Mitlesende,

gar keine Antwort irritiert mich und ich bin am Grübeln wodran das liegt.

Liegt es daran daß sich keiner eine fremde Exe auf dem Rechner ausführen lassen will? Kein Problem, ich zipp die durch die Exe bei mir entstandenen Dateien und lade es hoch.
Dann hat man nur einfache Dateien wie .frm, .vbp und die kann doch jeder VBler ruckzuck checken ob die gefährlich sind.

Liegt es an VB5, hat das keiner mehr? Auch kein Problem, dann nehm ich auch gerne eine in VB6 kompilierte Exe. Den mir hier vertrauten Namen vertraue ich blind und starte die Bedenkenlos.

Ich freue mich über jedwede Information.

Danke ^ Gruß
Reinhard

Hallo Reinhard,

gar keine Antwort irritiert mich und ich bin am Grübeln wodran
das liegt.

ich kann nur für mich reden.

Erst mal habe ich nur im Ansatz verstanden, wo das Problem liegt und vermute, daß ich Dir nicht helfen kann, auch wenn ich Dein ‚Experiment‘ nachvollziehe.

Du saugst aus dem Internet eine Anwendung und die tut nicht das Versprochene. Dann wird das an der Anwendung liegen, vermute ich.

Dazu kommt:
Die Anwendung ist dazu da, eine andere Office-Datei zu öffnen.
Hmmmm. Das kann mein VB6 auch so und ich erinnere mich noch, daß das auch mit VB4 schon kein Problem war.

Du willst also eine fehlerfreie Funktion von VB durch eine fremde, fehlerhafte ersetzen. Warum? Und wie soll ich Dir helfen? Mal vorausgesetzt, ich hätte ein Word-Dokument zum öffnen, könnte ich vermutlich Deine Fehlermeldung bei mir auch bewundern. Was der Programmierer aber falsch gemacht hat, werde ich nicht herausfinden.

Ich sehe nicht, daß ich Dir werde helfen können, wenn ich das Werkzeug, das ich für unnötig halte, auch noch lade, deshalb versuche ich es gar nicht erst.

So! Das ist, was ich bisher verstanden habe. An welcher Stelle irre ich mich da? Wie genau könnte die Hilfe aussehen? Wenn ich eine Fehlermeldung bewundere (Du weißt, ich kann kein Englisch) wird Dir das ja nicht helfen.

Gruß Rainer

Hallo Reinhard,

da sich diesem Problem keiner so recht annimmt. Hier eine Lösung :smile:

Also das Project ist in der Version VB6 geschrieben wurden. Das bedeutet das im Project File (*.vbp) 2 Eintraege vorhanden sind, womit VB5 nicht weiss damit anzufangen. Aber diese Eintraege sind eh unrelevant :smile:

Es handelt sich dabei um folgende Eintraege!

Retained
DebugStartupOption

Um das Project dennoch nutzen zu können, öffnet man einfach die Projectdatei mit einem Editor und entfernt folgende Eintraege

Retained=0
DebugStartupOption=0

Danach speichern und dann die Project Datei wie gewohnt mit VB laden.
Es ist nicht erforderlich irgendwo, irgendwelche Verweise noch zu setzen :smile: Diese sollten dann auch schon automatisch gesetz sein.

MfG Alex

Ps: Gerade mal an Reinhard sein Link getestet und volla Funzt :wink:

MfG Alex

Hallo Reinhard,

in der „propdemo.vbp“ stand der Eintrag
Retained=0

Richtig, den musst du unter anderem entfernen. Genauso, wie den

DebugStartupOption

und keinen anderen! Sonst geht es net mehr!

den habe ich ersatzlos gestrichen.
Dann wurde noch ein Schlüssel bemängelt, den habe ich auch
rausgeworfen (Namen leider vergessen)

Dazu muesste man wissen, welcher das gewesen ist!

Dann noch den verweis auf Comdlg32.oxc eingebaut weil danach
verlangt wurde.

Du meinst nachdem du das Teil geöffnet hast? Oder wann? Wenn du den Verweis dann gesetzt hast, hast du dann auch das OCX auf die Form gezogen und es entsprechend benannt? Das Fehlende Steuerelement wurde dann als Picturebox dargestellt. Hast du dieses dann von der Form entfernt ?

Jetzt kann ich im Editor die propdemo.vbp öffnen. Nur, danach
tut sich nix. Drücke ich auf F5 so kommt die Fehlermeldung:

Startformular oder Sub main() erforderlich.

Welches Formular ist denn als Start Formular im Project angegeben?
Existiert auch das Formular ?

Das sehe ich genauso, denn von Code ist nirgends was zu sehen.
Bei Ansicht sind die obersten 4 Punkte deaktiviert.

Hmm, das muesste man sehen, wie es ausschaut um dazu etwas genaueres zu sagen!

Bestätige ich die Fehlermeldung mit Ok oder schließe sie mit
dem Schließkreuz kommt die Fehlermeldung

Nicht genügend Speicher

Im Projekt Explorer Fenster steht zwar der name der vbp, aber
mehr auch nicht.

Ich denke mal durch deine Löscherei in der Project Datei hast du mind.! einen wichtigen Eintrag entfernt :frowning:

Danke ^ Gruß
Reinhard

Wenn du es auf krampf nicht hinbekommst, so kann ich dir das Project mal umgesetzt in VB5 zukommen lassen :wink:

MfG Alex

Hallo Alex,

in der „propdemo.vbp“ stand der Eintrag
Retained=0

Richtig, den musst du unter anderem entfernen. Genauso, wie
den
DebugStartupOption

und keinen anderen! Sonst geht es net mehr!

Genua, ich glaub das war der zweite, mehr hab ich nicht gelöscht *schwör*

Dann noch den verweis auf Comdlg32.oxc eingebaut weil danach
verlangt wurde.

Du meinst nachdem du das Teil geöffnet hast? Oder wann? Wenn
du den Verweis dann gesetzt hast, hast du dann auch das OCX
auf die Form gezogen und es entsprechend benannt? Das Fehlende
Steuerelement wurde dann als Picturebox dargestellt. Hast du
dieses dann von der Form entfernt ?

*Hüstel*, welche Form? Ich habe keine erstellt und dieser VB-Code wohl auch nicht :frowning:

Jetzt kann ich im Editor die propdemo.vbp öffnen. Nur, danach
tut sich nix. Drücke ich auf F5 so kommt die Fehlermeldung:

Startformular oder Sub main() erforderlich.

Welches Formular ist denn als Start Formular im Project
angegeben?
Existiert auch das Formular ?

Nö, da ist gar nix zu sehen.

Hmm, das muesste man sehen, wie es ausschaut um dazu etwas
genaueres zu sagen!

Verstehe ich nicht, wenn du noch VB5 haben solltest, dann netterweise diese Exe startest hast du die gleichen VB-Dateien wie ich. Wenn du dann probierst die zu laden kriegste doch garantiert die Hinweise auf die 2 Schlüssel. Okay, diese lösche ich/du.
Dann probierst du nochmal das zum Laufen zu bringen, dann kommt der Hinweis auf die fehlende ocx oder dll, hab jetzt nicht nachgeschaut.
Dann machst alles so wie ich es beschrieb und der Effekt ist, man sieht grad nix:frowning: kein Code, keine Form, kein Modul…

Bestätige ich die Fehlermeldung mit Ok oder schließe sie mit
dem Schließkreuz kommt die Fehlermeldung

Nicht genügend Speicher

Im Projekt Explorer Fenster steht zwar der name der vbp, aber
mehr auch nicht.

Ich denke mal durch deine Löscherei in der Project Datei hast
du mind.! einen wichtigen Eintrag entfernt :frowning:

Nein, ich habe nur die 2 Schlüssel liquidiert.

Wenn du es auf krampf nicht hinbekommst, so kann ich dir das
Project mal umgesetzt in VB5 zukommen lassen :wink:

Jaaaaaaaaaa, endlich mal eine verständliche Aussage von dir :smile:)

Ich habe halt nicht die Kenntnisse von Rainer um dir folgen zu können.
Und bedenke bitte, ich habe zwar neuerdings VB5 installiert und mit meinen hervorragenden Excel-Vba Kenntnissen *gg* ist es mir sehr leicht möglich per Vba ein „hello world“ in jede beliebige Zelle reinschreiben zu lassen.

In VB5 gelang es mir noch nicht eine Form erscheinen zu lassen die „hello world“ anzeigt.
Aber faireweise und zu meiner Ehrenrettung muß ich sagen ich habe letztlich VB5 erst 3mal gestartet.
Nach der Installation und kurz danach nochmal um das mit „hello world“ hinzukriegen.
das dritte Mal ist jetzt die aktuelle Problematik, wobei ich dann dazu schon mehrmals VB5 geöffnet habe/hatte.

Okay, das mit „hello world“ kriege ich locker und schnell hin wenn ich mir die Zeit nehme in der VB-Hilfe zu lesen oder ein einfaches Buch wie „VB für Dummies“ kaufe.

Die aktuelle Problematik, also warum ich es nicht hinkriege diese VB-Dateien zum Laufen zu kiregen würde bestimmt länger dauern.
Deshalb nehme ich dein Angebot sehr gerne an.

Gruß
Reinhard

MfG Alex

Hallo Reinhard,

Genua, ich glaub das war der zweite, mehr hab ich nicht
gelöscht *schwör*

Nein! Der steht 3 Eintraege unter dem Retained :smile:
Mal zur Veranschaulichung, das File

Type=Exe
Reference=\*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\WINNT\System32\stdole2.tlb#OLE Automation
Reference=\*\G{93769740-DE48-11D2-B7C8-A62255602516}#1.4#0#..\dsofile.dll#DS: OLE Document Properties 1.4 Object Library
Object={F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0; comdlg32.ocx
Form=FileProp.frm
IconForm="FileProp"
Startup="FileProp"
HelpFile=""
Title="FilePropDemo"
ExeName32="FilePropDemo.exe"
Command32=""
Name="FilePropDemo"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=3
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="Microsoft Corporation"
CompilationType=0
OptimizationType=2
FavorPentiumPro(tm)=0
CodeViewDebugInfo=-1
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
**Retained=0**
ThreadPerObject=0
MaxNumberOfThreads=1
**DebugStartupOption=0**

[MS Transaction Server]
AutoRefresh=1

*Hüstel*, welche Form? Ich habe keine erstellt und dieser
VB-Code wohl auch nicht :frowning:

:wink: DU hast doch wenn du das Exe File installierst, folgende Datei Struktur

c:\DSOFile
 \*VBTEST
 \*FileProp.frm
 \*FileProp.frx
 \*ProbDemo.vbp
 \*ProbDemo.vbw 
 \*dsofile.dll
 \*License.txt

Also die *.vbp Datei ist deine Project Datei. Dazu gehört auch die *.vbw. Ändern musst und darfst du nur die *.vbp Datei!
Die *.frm Datei ist deine Form. Dazu gehört auch die *.frx Datei!

In der *.frm Datei stehen zum Bsp. alle Objecte die genutzt werden sollen und unter anderem auch der source :wink: Schau dir das ruhig mal an . Aber aendere nichts.

So nun öffnest du mal die vbp Datei. Am besten ist es mit dem Editor, der mit Win ausgeleifert wird. File makieren, Shift druecken und dann die rechte Maustaste. Aus dem Popup Menu wählst du dann öffnen Mit aus und gibst dort den Editor an :wink:
Nun lösche bitte die besagten 2 Eintraege. Mehr nicht! Danach schliesse das *.vbp File wieder :smile: Nun noch ein Doppelclick drauf und volla, das Teil sollte seinen Dienst tun :wink:

Du musst nirgendwo einen Verweis setzen! Durch die Installation wird die DLL schon bekannt gemacht und der verweis auf die DLL sollte schon eingetragen sein! Wenn das nicht der Fall ist, so mache mal folgendes!

Dein VB ist offen und das teil geladen. Klicke nun auf Project -> Verweise. Nun sollte sich ein Fenster öffnen, wo ein Haufen Mist drinnen steht. Jeder Eintrag hat ein Kästchen davor zum anklicken ( Checkbox) Schaue mal ob dort der Eintrag
DS:open_mouth:LE Document Properties 1.4 Object Library gesetz ist. Wenn du ihn makierst solltest unten den Pfad dazu sehen. Dort sollte nun c:\DSOFile}dsoFile.dll stehen!
Wenn das der Fall ist, so ist der verweis akurat gesetzt. Wenn nicht klicke einfach auf Hinzufügen und gebe dort die DLL Datei an!

Nun siehst du doch, ganz Rechts den sogenannten Project Explorer! Wenn nicht so kannst du ihn ueber Ansicht Project explorer einschalten! Dorthin gelangst du wenn du mit der Maus rein klickst oder halt STRG + R drueckst :smile:

Dort sollte nun folgendes stehen!

- FileProbDemo(ProbDemo.vbp)
 -Formulare
 FileProp(Fileprop.frm)

Du siehst das ich immer ein - davor gemacht habe. Es kann sein das dort auch ein + steht. Das bedeutet dann das die Eintraege eingeklappt sind. Also rauf aus + klicken , dann siehst du das und aus dem + sollte ein - werden :smile:

So, nun siehst du doch den Eintrag FileProp(FileProp.frm) Mache dort mal einen Doppelclick drauf! Nun solltest du wenn nicht schon vorher das Formular FileProp sehen!

Solltest du beim laden einen Hinweis bekommen das ein OCX nicht geladen werden konnte, so kann es sein das es nicht gefunden wurde.
Aber macht nichts :wink:

Ganz Links siehst du die werkzeugleiste, die du aus VBA kennst. Dort wo die textboxen etc. sind zum draafziehen. Mach dort mal einen Rechtsklick drauf und waehle aus dem menu Komponenten!
Es öffnet sich wieder nen Fenster :wink:
Das kommt dir sicherlich sehr bekannt vor :smile:
So nun musst du wissen welches OCX dir fehlt! In dem Demo ist als OCX nur der Commondialog vorhanden! Also kann auch nur der fehlen. Suche dort mal in der Liste folgenden Eintrag.

Microsoft Common Dialog Control und irgendne Zahl. Bei mir ist es die 6.0 :smile: Selektiere die Checkbox davor und klicke dann auf Übernehmen und danach auf OK, oder gleich auf OK, ist das selbe :wink:

Nun siehst du das in der Werkzeugleiste ein neues Element auftaucht! Diese ziehst du mal bitte auf die Form. Ändern musst du rein garnichts daran :smile:

So spätestens nun sollte das Teil eigentlich laufen :smile: Probiere es mal indem du STRG+F5 drueckst :wink:

Du hast geschrieben das du eine Meldung bekommen hast das das Starformular nicht gefunden wurde oder sowas :s

Unter VB kannst du etliche Formen machen. Du kannst dein Program auch von jeder beliebigen Form aus starten :smile: Du musst es dem halt nur sagen. Auch ist es manchmal ratsam das Proggi aus einer Sub starten zu lassen um bsp. ein mehrfachstart zu verhindern etc. Und genau auch das geht. Die Frage ist nun wie?

Nichts einfacher als das :smile: Gehe in den Project Explorer! Dort steht der Eintrag FilePropDemo(FileProp.vbp) Klicke diesen mal mit rechts an und dann aus dem Popup Menu Eigenschaften!

Hier kannst du die Program Eigenschaften festlegen. Sprich wo gestartet werden, wie compiliert werden soll etc. Schau dir das mal in Ruhe an :wink:

Und genau gleich auf der ersten Seite, siehst du Startformular. Dort sollte folgendes in der Combobox stehen.

Sub Main
FileProp

Wählst du dort Sub Main aus, so musst du ein Modul erstellen und eine Sub mit dem Namen Main. Dann beginnt das program genau dort :smile: Aber das wollen wir nicht. Wieso auch? Waehle einfach fileProp aus und er startet gleich in der Formm :smile:

Spätestens nun sollte das Dinge aber seinen Dienst machen :smile:

Nö, da ist gar nix zu sehen.

War vielleicht im Project Explorer nicht alles aufgeklappt oder die Form nicht ausgewaehlt :wink:

Verstehe ich nicht, wenn du noch VB5 haben solltest, dann
netterweise diese Exe startest hast du die gleichen VB-Dateien
wie ich. Wenn du dann probierst die zu laden kriegste doch
garantiert die Hinweise auf die 2 Schlüssel. Okay, diese
lösche ich/du.

Genau und dann läuft das Dinge anstandslos :smile:

Dann probierst du nochmal das zum Laufen zu bringen, dann
kommt der Hinweis auf die fehlende ocx oder dll, hab jetzt
nicht nachgeschaut.

Wie lautet die Fehlermeldung genau? Kann es vlt. sein das die DLL beim Setup ( ausführen der EXE nicht registriert wurde? Abhilfe schafft den Verweis neu zu setzen :smile:

Dann machst alles so wie ich es beschrieb und der Effekt ist,
man sieht grad nix:frowning: kein Code, keine Form, kein Modul…

Die Form auswaehlen Reinhard *gg* Der Code steht in der Form. Wenn du die Form siehst und deren Elemente, dann druecke mal F7, so siehst du dann den Source. Um wieder die Form zu sehen druecke halt Shift F7 oder doppelklick im Project Explorer auf die Form oder ueber dem menupunkt Ansicht glaub:wink:

Nein, ich habe nur die 2 Schlüssel liquidiert.

Hm, das ist kurious!!!

Jaaaaaaaaaa, endlich mal eine verständliche Aussage von dir

-))

Ich habe halt nicht die Kenntnisse von Rainer um dir folgen zu
können.
Und bedenke bitte, ich habe zwar neuerdings VB5 installiert
und mit meinen hervorragenden Excel-Vba Kenntnissen *gg* ist
es mir sehr leicht möglich per Vba ein „hello world“ in jede
beliebige Zelle reinschreiben zu lassen.

Naja ich habe dir nun eine Schritt für Schritt Anweisung gegeben *gg*

In VB5 gelang es mir noch nicht eine Form erscheinen zu lassen
die „hello world“ anzeigt.

Wenn du magst, erklärt dir Rainer oder ich das gerne. Das ist total einfach *zwinker*

Aber faireweise und zu meiner Ehrenrettung muß ich sagen ich
habe letztlich VB5 erst 3mal gestartet.
Nach der Installation und kurz danach nochmal um das mit
„hello world“ hinzukriegen.
das dritte Mal ist jetzt die aktuelle Problematik, wobei ich
dann dazu schon mehrmals VB5 geöffnet habe/hatte.

Okay, das mit „hello world“ kriege ich locker und schnell hin
wenn ich mir die Zeit nehme in der VB-Hilfe zu lesen oder ein
einfaches Buch wie „VB für Dummies“ kaufe.

Dafür brauchst du kein Buch Reinhard. Dazu gibt es das Forum :smile:

Die aktuelle Problematik, also warum ich es nicht hinkriege
diese VB-Dateien zum Laufen zu kiregen würde bestimmt länger
dauern.
Deshalb nehme ich dein Angebot sehr gerne an.

Mail ist unterwegs :smile:

Gruß
Reinhard

Mfg Alex