Results 1 to 15 of 15
  1. #1
    Wasser2021 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2021
    Posts
    10

    Path und Dateiname in eine Stringvariable als MsgBox ausgeben.

    Hallo VBA Freunde. Ich gestehe ich tue mich mit VBA wirklich schwer.. Brauche Hilfe möchte im Grunde nur eine Tonaufzeichnung indizieren um diese weiterverarbeiten zu können..
    Deshalb hier der Versuch die notwendigen Variablen auszuprobieren..

    Private Sub Option18_Click()
    'Pfad, Dateinahmen in eine Stringvariable speichern
    'Beispiel: C:\Temp\Blabla.wma
    Dim sPfad As String, sName As String
    sPfad = "C:\Temp" 'anpassen


    sName = "blabla.wma" 'anpassen
    MsgBox "sPfad", "sName"
    End Sub

    'Geht leider nicht, Meldung Laufzeitfehler 13 Typen unverträglich
    In einem anderen Beispiel wird nur der Variablen Namen angezeigt aber nicht der Inhalt?
    Z. B.
    Dim V1 asString
    V1 = "Dateipath"
    MsgBox V1
    Angezeigt wird nur V1 nicht der Inhalt?

    Es wäre nett, wenn mir hier jemand auf die Sprünge helfen könnte.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,941
    for the benefit of responders, this is a translation of the OP's post

    Hello VBA friends. I confess I have a really hard time with VBA ..
    I need help, basically just want to index a sound recording in order to be able to process it further ..
    Therefore the attempt to try out the necessary variables here.

    Code:
    Private Sub Option18_Click ()
    'Save path, file name in a string variable'
    Example: C: \ Temp \ Blabla.wma
    Dim path As String, sName As String
    sPfad = "C: \ Temp" 'adjust
    sName = "blabla.wma" 'adjust
    MsgBox "path", "sName"
    End Sub

    Unfortunately this does not work, message runtime error 13 types incompatible
    In another example only the variable name is displayed but not the content?
    E.g.Dim V1 asString
    V1 = "file path"
    MsgBox V1
    Only V1 is displayed, not the content?

    It would be nice if someone could help me out here.



  3. #3
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    Code:
    Private Sub Option18_Click ()
    'Save path, file name in a string variable'
    'Example: C:\Temp\Blabla.wma
    Dim path As String, sName As String, sPfad as string
    sPfad = "C:\Temp\" 
    sName = "blabla.wma"
    Path = sPfad & sName
    MsgBox "path=" & Path
    End Sub
    Last edited by davegri; 07-03-2021 at 08:42 PM. Reason: format cleanup

  4. #4
    Wasser2021 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2021
    Posts
    10
    Hi VBA GUI's it would be nice, if someone has a solution for the problem, put a data path into a string variable and declare a MsgBox to approve it, for further usage ?

  5. #5
    Wasser2021 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2021
    Posts
    10
    Thanks for the translation, I'm new here and my English, like my VBA skills, could be improved. :-)) It would be nice if someone would have mercy to help me on the "jumps" (German slang)
    To get to the heart of the problem, it is about the correct definition of the variables in the path of a file (path, file name, extension) for further processing. To check that, I have chosen the MsgBox here.
    But it doesn't work. Error message type is incompatible.
    Thanks in advance.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    Have you even tried davegri's code?

    It just worked fine for me.?

    Yours had spaces in the path, where spaces are not allowed?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    Wasser2021 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2021
    Posts
    10
    Quote Originally Posted by Welshgasman View Post
    Have you even tried davegri's code?

    It just worked fine for me.?

    Yours had spaces in the path, where spaces are not allowed?
    Hello Welshman, I read your comment and agreed to it. Well it works the way I need it now.
    My next step is to change the filename with an index, for example a simple counter.
    I need it because I have my own database to learn a foreign language, in this case Suomi (Finnish) and English together.

  8. #8
    Wasser2021 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2021
    Posts
    10
    Hello dave gri, thank you very much for your help.
    I can now add a counter to my code to modify the filename with it. I need this for my learning database to practice pronunciation.
    I will add a for next loop for this.
    I had originally defined an OLE field for the sound in my database table. However, the system hangs up. That's why I saved the address of the sound recording as a text field with the path and the file name. Unfortunately, there is no field property in Access that enables it to be called, such as a hyperlink. I very much hope that I can solve the problem with the sound recordings after all, so I could finally start learning the language properly. If you can help me there again, I will of course be happy to accept it. Thank you and greetings from Finland.

  9. #9
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    Unfortunately, there is no field property in Access that enables it to be called, such as a hyperlink.
    Have a look at this:

    Hyperlink.Follow method (Access) | Microsoft Docs

    The hyperlink address in the example is a website URL, but it can be a path on your hard disk.

  10. #10
    Wasser2021 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2021
    Posts
    10
    High VBA Fans :-)) I am a step further, i could start my voice recorder and modify the sound filename with record number into predefined location.
    The next step is to start the media player to hear the recorded sound. But this dammed VBA will not understand my intention.

    MsgBox "Sound begins" 'Ok
    path = path & record & sName 'ok
    MsgBox "path =" & path

    StartMedia player:sCommand = ("wmplayer.exe / path")
    ' Here is the Problem... I can start MP, but could not give the filename with it ?
    ' has someone an idea to start the MPlayer with filename. In my case filename is content of ' variable "path"

    CreateObject ("WScript.Shell"). Run sCommand, 1, True

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    I would expect it would be more like
    Code:
    StartMedia player:sCommand = ("wmplayer.exe / " & path)
    

    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    or
    = ("wmplayer.exe" & "/" & path)?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    Wasser2021 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2021
    Posts
    10
    Hi guys, thank you very much for all of your answers. I was able to solve all of my VBA problems, now. My database is now up and running and I can finally start learning my Finnish and English at the same time. My original problem is handling the VBA editor. Usually I don't understand the syntax, sometimes a comma, sometimes a bracket or "this special character is necessary in print or messages.
    Example: This prompt:
    doCmd.copyObject, ([target database], [new name], [source object type as AcObjectty = ac standard]], [source object name]

    I really don't understand what VBA doesn't want?
    I'm assuming a table in one project will be copied to another? But what does NewName mean? Anyway, I spend a lot of time with it and will go further. I am glad to have friends here who are willing to help, even if they are unprofessional.

  14. #14
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    I am glad to have friends here who are willing to help, even if they are unprofessional.
    Care to explain that? It comes across as an insult to somebody, but who was acting in that manner? Perhaps you meant to say "even if they are not professionals." ?

    Regarding [new name] - I didn't see it in a prior post so I imagine you copied it from somewhere. Anything in brackets [ ] is usually a field name. Often when looking at sample code you'll see words that are meant to describe what should go in there but it is done in a short form. Whoever provides the sample could put

    [use your own name here for the name of the new item]

    but it's much easier to use [new name] expecting the reader will make the connection. You can see that it is explained in a different fashion here. Note that in the sample you posted there is a space between 2 words that represent the name. You should not use special characters (except perhaps for underscore) and never spaces between words that make up an object name. At the link I provided, there is no space in the example syntax thus brackets are not used. If there are no spaces but there are brackets, it will work fine but it is unnecessary typing if used.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    even if they are unprofessional
    I expect this is just a misunderstand of English nuance.

    Attachment 45672

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 10-12-2020, 01:19 PM
  2. Replies: 2
    Last Post: 08-22-2018, 12:15 PM
  3. Replies: 6
    Last Post: 05-27-2014, 05:41 AM
  4. Replies: 3
    Last Post: 11-24-2012, 08:56 AM
  5. Yes No msgbox
    By imintrouble in forum Access
    Replies: 3
    Last Post: 10-14-2011, 02:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums