none
Is there a way to send a string to the clipboard so i can use control paste to put what in clipboard in a spot that takes a string? RRS feed

  • Question

  • What I am trying to do, is, to rename a access object with a custom string I created.

    seems I need to rename a: table, standard module, the name of the VBA Project.

    the table, standard module, and the project name are easy to change, just right click on the name, and in box that shows when pick rename just paste in a NEW name.

    the template database I use to create new databases, already has names for these objects,

    because I needed to have the NEW set of objects have a different name than the template.  Do expect to have many databases created from this template, and having the NEW names be very close to the template makes much easier for database to be maintained.

    do to all these created the same day.  seemed real easy way was to add a string like 20170112  ( if current date was 1/14/2017 ) to be added to end of tableName .  or what ever the object name was.

    If I cannot change the values of the names of the objects in code at run time, I could at least do manually . 


    Mark J

    Sunday, January 15, 2017 5:44 AM

Answers

  • Hi PuzzledByWord,

    I agrees with the suggestion given by the Daniel  Pineault and Imb-hb.

    here I think that we are misunderstanding something in your issue.

    can you please again try to describe your issue with clear requirements and details.

    so we can again try to provide you a  suggestion to solve the issue.

    do you want to rename the objects by code?

    or you just want to copy the new name to clipboard programmatically and then paste it by right click.

    if yes, then also you need to assign name to clip board every time to rename new object.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by PuzzledByWord Friday, January 20, 2017 7:49 AM
    Monday, January 16, 2017 3:27 AM
    Moderator

All replies

  • because I needed to have the NEW set of objects have a different name than the template.  Do expect to have many databases created from this template, and having the NEW names be very close to the template makes much easier for database to be maintained.

    Hi Mark,

    On the moment I have more than 90 applications running, and I think I have met the same puzzle as you have now.

    Instead of renaming objects in code at run time (if possible at all) I use general routines, where the object(s) is/are passed as argument. Independant of the application the objects can use the same (abstract) variable, but the real object is determined by the value of the parameters.

    Imb.

    Sunday, January 15, 2017 9:37 AM
  • Hi Imb,

    Your idea I am going to have to think about.  Before I can figure out what questions I need to ask about this.

    By the way, I would not be renaming objects at run time. 

    I would only be renaming the objects once when I first create the new database from the template.  And not after first name change.

    This comes up during the time I am creating a new database from one of my templates,

    During that time I am creating a new database from one of my templates, In the Visual Basic Editor I have set a reference to the template I am using.

    So until I can remove the reference to the template in the NEW database, I will have for example two standard modules, both called basUtil.   One in the template other in the new database.

    that I will remove the reference to the template after first part of new database is set up.  then there will be NO objects with the same name showing in the visual basic editor.

    thanks for the info.

    Mark


    Mark J

    Sunday, January 15, 2017 10:44 AM
  • I'm still not sure what your actual question is.  Your title asks about the clipboard, but your body is talking about appending the date to object names.

    You can copy any string, at any time, by selecting it and then pressing CTRL+C.  There are also APIs that can easily be used should you wish to do the same through VBA coding.

    I'm also curious why you'd have some many copies of objects.  This is not normal database design, but without understanding your process I can't offer suggestions.


    Daniel Pineault, 2010-2016 Microsoft MVP Professional Support: http://www.cardaconsultants.com MS Access Tips and Code Samples: http://www.devhut.net


    Sunday, January 15, 2017 12:56 PM
  • So until I can remove the reference to the template in the NEW database, I will have for example two standard modules, both called basUtil.   One in the template other in the new database.

    that I will remove the reference to the template after first part of new database is set up.  then there will be NO objects with the same name showing in the visual basic editor.

    Hi Mark,

    Why do you need the reference to the template in the beginning, to remove later on? Couldn't you simple copy the basUtil modules from the template to the new database? And why do you need the different names?

    On this point our systematics differ. All the modules that are "general" I have in a separate database that is referenced by all applications. This referenced database contains more than 95% of all functionality in any application. Besides I have an "empty" database, that contains the (empty) tables to store the metadata for the specific application. Starting a new databases is running a routine that copies the "empty" database, rename it, sets the projectname, etc. What is left is naming the table names, and the fields including their characteristics.

    Imb.

    Sunday, January 15, 2017 7:19 PM
  • Hi PuzzledByWord,

    I agrees with the suggestion given by the Daniel  Pineault and Imb-hb.

    here I think that we are misunderstanding something in your issue.

    can you please again try to describe your issue with clear requirements and details.

    so we can again try to provide you a  suggestion to solve the issue.

    do you want to rename the objects by code?

    or you just want to copy the new name to clipboard programmatically and then paste it by right click.

    if yes, then also you need to assign name to clip board every time to rename new object.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by PuzzledByWord Friday, January 20, 2017 7:49 AM
    Monday, January 16, 2017 3:27 AM
    Moderator
  • Sorry about not being clear enough.

    I have two different code issues in my post. For two different databases.

    I did think the same answer would solve both issues.

    #1 issue that is MOST important is I want to RENAME OBJECTS BY CODE. At the time NEW database was created.

    The objects would be a table, a standard module, for example.

    I know I could do a CTRL+C  to copy and then paste a string,   BUT I do NOT know how to do that in code, VBA code that is.  

    I am trying to automate as much as possible to reduce amount of coding and debugging needed. And less chance of forgetting to add something to code.

    AND I WOULD LIKE TO VERY MUCH BE ABLE TO PASS A STRING TO THE CLIPBOARD SO I COULD PASTE THE VALUE.  using VBA CODE THAT IS. 

    To make it easy for me to explain why I wanted to add a date to some access objects is this.

    I have several access template I have created with most of the foundation code, in modules, form, report, standard modules, class modules.   

    So I have to add very little customized code to create and add to each requested database. 

    The requested databases often had 90% of code done and tested in one of my templates.  Good reason to use templates.  Made for a lot less work and time for me, at least for the requested database I had a template for.

    Major problem I ran into after several years was, some of these databases needed to have a reference to another database. AND some of the access objects had the same name. 

    So if code referred to a object and there were two objects with the same name, but in different databases, code could not tell which object with the same name to use.

    The names of the objects made real clear what object was, and used for.

    and with my documentation on the base template, made maintenance of code very quick and easy.

    coming up with a different name for each object in the new database created from a template would be a pain.

    the simplest and quickest way I could think of to make the names of the OBJECTS in the NEW database created from a certain TEMPLATE   UNIQUE was to add the date to the end of the name at the date that the NEW database was created.     As a rule I do NOT add a date to an object, No Need, except it seems in this situation.

     

     


    Mark J

    Wednesday, January 18, 2017 2:00 AM
  • Hi Imb,

    why I need the reference to the template is

    I have one database loaded with code to help me code, debug, and document my code as I write it.

    It is very helpful to have access to those functions I created while writing new code for a new project.

    but I do not need them after database is created. So then I remove the reference to the old database.


    Mark J

    Wednesday, January 18, 2017 2:15 AM
  • Hi Imb,

    Your way seems a lot better than mine.   

    I do have a question on the "empty" database that contains the tables to store the metadata for the specific application. By metadata do you mean something like table names like "employee" and "employee ID number" for a field in table employee?

    How do you rename the copied empty database? If you rename it in code that is.

    How do you set the project name? If you rename it in code that is.


    Mark J

    Wednesday, January 18, 2017 2:27 AM
  • Hi PuzzledByWord,

    if you want to rename Table, Form, macro , module, Query etc. then you can use DoCmd.Rename Method.

    example:

    DoCmd.Rename "Old Employees Table", acTable, "Employees"
    

    Reference:

    DoCmd.Rename Method (Access)

    AcObjectType Enumeration (Access)

    For coping to clip board please visit the link below.

    How to copy to clipboard using Access/VBA?

    example:

    set text:-
    
    Dim clipboard As MSForms.DataObject
    Set clipboard = New MSForms.DataObject
    clipboard.SetText "A string value"
    clipboard.PutInClipboard
    
    get text:-
    
    Dim clipboard As MSForms.DataObject
    Dim strContents As String
    
    Set clipboard = New MSForms.DataObject
    clipboard.GetFromClipboard
    strContents = clipboard.GetText

    Send Information to the Clipboard

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 18, 2017 4:27 AM
    Moderator
  • Deepak,

    Thanks very much

    the DoCmd.Rename Method works great.  I had hoped it was so simple.

    I do have a question about MSForms.DataObject

    Am I doing something wrong?

    I could only find it in documentation for this in VB.Net   I could not find it in VBA 7.1 64 bit either.  

    First I thought I needed to create a reference to "MS Forms". 

    I thought I had seen something like MS Forms or Microsoft forms in the list of references. I sure cannot find it now, if it was ever in the list in the first place.

    The closest I was able to get was "acDataObjectType Enumeration used with GoToRecord method"  as Class    and acActiveDataObject  as member.

    I did go to the links you listed. I did see and copy the code to put in a class module that uses API calls to get string to the clipboard.

    it is on my list to add to my code base once I get it installed, testing and running on my machine.

    for a simple seeming task, a lot of code.

    so is MSForms.DataObject    only for VB not VBA?  If so, sorry I thought I mentioned this was for VBA 7.1.

    Thanks again for the help.

    Mark J


    Mark J

    Friday, January 20, 2017 7:47 AM
  • Hi PuzzledByWord,

    you had mentioned that,"I thought I had seen something like MS Forms or Microsoft forms in the list of references. I sure cannot find it now, if it was ever in the list in the first place."

    if it is not in list of references then it is possible that FM20.DLL is missing.

    you can download it from link below and refer the instructions to install it.

    Download Fm20.dll for Windows 10, 8.1, 8, 7, Vista and XP

    then you can check the references again and add it.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 23, 2017 5:03 AM
    Moderator
  • Deepak,

    Thanks. With that info I was able to track info on file.

    Turns out now I only have in one of my backup files dated 1/15/2013  

    both FM20.dll and FM20ENU.dll

    Only wonder if way to check if one or both files were damaged somehow before were moved to a backup file?

    Mark J


    Mark J

    Tuesday, January 24, 2017 12:17 PM
  • Hi PuzzledByWord,

    you had asked,"if way to check if one or both files were damaged somehow before were moved to a backup file?"

    to check for any damaged or corrupted file you can use "System File Checker Tool".

    System File Checker is a utility in Windows that allows users to scan for corruptions in Windows system files and restore corrupted files. This article describes how to run the System File Checker tool (SFC.exe) to scan your system files and to repair missing or corrupted system files. If a Windows Resource Protection (WRP) file is missing or is corrupted, Windows may not behave as expected. For example, some Windows functions may not work, or Windows may crash.

    For more detailed information with examples , please visit link below.

    Use the System File Checker tool to repair missing or corrupted system files

    Regards

    Deepak 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 25, 2017 12:58 AM
    Moderator