+ Reply to Thread
Results 1 to 6 of 6

How do I say if file name = then run this else go to next

  1. #1
    Registered User
    Join Date
    12-24-2009
    Location
    Texas
    MS-Off Ver
    2019
    Posts
    16

    How do I say if file name = then run this else go to next

    I have made comments where I would like things to happen in red.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: How do I say if file name = then run this else go to next

    Try:

    Please Login or Register  to view this content.
    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    12-24-2009
    Location
    Texas
    MS-Off Ver
    2019
    Posts
    16

    Re: How do I say if file name = then run this else go to next

    It looks like that is working.

    The save and saveas function is not working completely either. Can you take a look at my code for that. It crashes excel when I go to save. I want it to disable save and saveas completely. That also means grey it out on the menu or remove it from the menu. They must use the submit button to both save then email.

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: How do I say if file name = then run this else go to next

    Hi,

    You can only have one Workbook_Open event code so you would need to pop your code to disable the menu items at the start of your other event code.

    I didn't get any errors when I tested it. To have the option to save from a button pop this code in a standard module:

    Please Login or Register  to view this content.
    And change your BeforeSave event code to this:

    Please Login or Register  to view this content.
    You will then also be able to attach the save_file macro to a button from the forms toolbar that the user will be able to click as required.

    Hope it helps,

    Dom

  5. #5
    Registered User
    Join Date
    12-24-2009
    Location
    Texas
    MS-Off Ver
    2019
    Posts
    16

    Re: How do I say if file name = then run this else go to next

    I wanted to ensure that both save and save as are disabled I have it function correctly now. Only thing i need to do is make sure that on submit button the file is saved and emailed with the code I have for save_file and Sub SendMail. I have a submit button created how do I get the code into the submit button for the save and email function.


    Please Login or Register  to view this content.

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: How do I say if file name = then run this else go to next

    You can either combine the save and email code into one procedure or have an additional one like this that will run each in turn:

    Please Login or Register  to view this content.
    If you use a button from your Forms toolbar you can then just right click on it and assign the above macro to it.

    From your post I'm assuming that you have all the above code on the ThisWorkbook code page of your workbook's VBA project. Everything apart from the Workbook_Open and Workbook_BeforeSave code should really sit within a standard VBA module rather than there. To add a module to your project just right click on it in the project explorer and select Insert...Module.

    Dom

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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