+ Reply to Thread
Results 1 to 11 of 11

button click event

  1. #1
    Registered User
    Join Date
    01-16-2014
    Location
    PA
    MS-Off Ver
    Excel 2010
    Posts
    50

    button click event

    I had to alter my beforesave coding because it was just causing problems when I need to code something. So, instead, I created a button that is titled saved and the end-user clicks on that to save the data they entered in the main form which is an .xlsm format but it saves it as another file name with another file extension. The extension is .xlsx. When I attempt to save, it will say it was saved but then when I try and access the file saved I get this error:

    Excel cannot open '123456789101 john doe 10-20-2013.xlsx' because the file format or file extension is not valid. verify the file has not been corrupted and the file extension matches the format of the file.

    Again, I cannot put this in a beforesave and had to do a button because beforesave causes issues with other things I am doing with beforesave. So, the button works although I cannot open the files I create without the error. I am sure it has something to do with I need to code something in the button to say I want to save as a macro free workbook?

    here is my code:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: button click event

    try changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    01-16-2014
    Location
    PA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: button click event

    That did not work either. It gives me an error of:
    compile error
    named arguement not found and that is on the filetype:=51

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: button click event

    Sorry. Should have tested first. Trying to work by memory. Its fileformat not type.

    Please Login or Register  to view this content.

    e/ It will give you a warning telling you you're saving as a macro free workbook. This can be supressed with:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-16-2014
    Location
    PA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: button click event

    Well, it almost works, but it renames my original excel which is my template that is not to be renamed. The way I had it set up in the beforesave, anything the nurse enters on the main template when they click the blue disk, it auto saves to another location using the items in 3 cells. cell 1 claim number, cell 2 member name, cell 3 date of service. But, that messes up doing it in beforesave.

    So, I created a save button instead and put the code in there so when they click the save button, it is to look at the 3 cells and select those and then saveas a new xls or xlsx in the path listed but not change the name of my template or workbook because they will continue to enter their audit data which could be 50 separate audits, creating 50 separate workbooks all while never chnging the name of my original workbook, original template.


    I don't want the current workbook to change its name. I only want what they enter to saveas something else going somewhere else.

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: button click event

    Well you can't "make a copy" of a workbook with SaveCopyAs and just change the extension. If you're making a copy of an xlsm the extension needs to reflect as such.

    It could be as easy as changing
    Please Login or Register  to view this content.
    if you have no problem keeping the filetype macro enabled.

  7. #7
    Registered User
    Join Date
    01-16-2014
    Location
    PA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: button click event

    That works. But now the next dilemma. Because it saves it as .xlsm, I open another workbook that has 17 macros built to gather all these audits they create, like this week 50 of them and move them into a single workbook so I can copy the fields on the workbook into 1 spreadsheet to import to an Access DB. We have to do it this way. I know there are easier methods but we have no funding so we have to do it for free and it has to be healthcare privacy compliant so cannot use any online free based tools. Excle and Access is it and it has to be within my limited coding ability. I am a SAS programmer.

    That being said, now my macros that I have don't work to import the files because they are .xlsm and not .xls or .xlsx.........is there a way to turn it off or change the path upon attempting to import or something??? My macro code to get all these sheets is:

    Please Login or Register  to view this content.
    This is why I was trying to change the extension in the audit form and not this import the sheets in my other workbook because these macros I set up months ago and have worked just fine until management wanted to make the form more automated for the nurses.....

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: button click event

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-16-2014
    Location
    PA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: button click event

    I did try that. But because it is now back to a .xlsm, macro enabled set of sheets, then it has all these pop ups when I try and import. So I will research online how to disable the macro events so they just import smoothly without any user having to do a bunch of click click click click for the pop-ups or maybe research how to convert on import to .xlsx or something that is macro disabled. Thanks.

  10. #10
    Registered User
    Join Date
    01-16-2014
    Location
    PA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: button click event

    I got it. I put in prior to my import of all the sheets code
    Please Login or Register  to view this content.

  11. #11
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: button click event

    You might want to set it back to true before the end of the macro.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Call button click event from a button on anther sheet
    By ajaykgarg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-25-2010, 09:27 AM
  2. Add Code To Button Click Event Using VBA
    By chergh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2009, 06:24 AM
  3. [SOLVED] Command Button - On Click Event
    By sharonm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-27-2006, 08:20 AM
  4. event with commandbar button right-click?
    By RB Smissaert in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-13-2005, 09:05 AM
  5. Automate a button click event
    By JD in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-08-2005, 08:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1