+ Reply to Thread
Results 1 to 4 of 4

If then statement depending on getopenfilename type

  1. #1
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    If then statement depending on getopenfilename type

    Hi Everyone,

    I was hoping someone could help me out with an If - Then statement I would like to make.

    I have a macro in excel that finds and replaces text in a powerpoint template. It lets me choose the file and then does the find and replace. I've made it so it lets me choose any file, so i would like to know how to phrase the if then statement to where if the person chooses a powerpoint file it goes through the macro, and if they choose a word document it will run a different set of code.
    I already have the code for the powerpoint macro (in research stage for find and replace on word docs).
    So the first thing it asks is what i would like to open-
    Please Login or Register  to view this content.
    How would I write the if then statement to look at the file type chosen so that if newfn = powerpoint it runs that macro and if its a .docx it runs a something else?

    Side note: Does anyone know how to find a list of the file filters excel vba is able to run during a getopenfilename or getsaveas? I've tried googling it but cant find anything.

    Thanks in advance for your help, this forum has been a great learning tool.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: If then statement depending on getopenfilename type

    Hi

    this is an example for file filters and getting the extension of a selected file:
    Please Login or Register  to view this content.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: If then statement depending on getopenfilename type

    Basically you can add every file extension you want

    ... slow forum -> double post .... sorry

  4. #4
    Registered User
    Join Date
    05-14-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    78

    Re: If then statement depending on getopenfilename type

    thanks, that helped a ton!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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