+ Reply to Thread
Results 1 to 4 of 4

Refer .font.name, .font.size, line.dashstyle to a cell instead of hard coding.

  1. #1
    Registered User
    Join Date
    09-16-2016
    Location
    TN
    MS-Off Ver
    2010
    Posts
    3

    Refer .font.name, .font.size, line.dashstyle to a cell instead of hard coding.

    So, this may be an easy question, but I'm new at this and trying to learn. I'm creating a basic macro template, where the user can setup a custom text box, and just create as many as they need and have them formatted the same way. My code that works, looks like this:
    Please Login or Register  to view this content.
    Now, what I want to do is, allow them to select the font, the font size, and the outline of the box from a drop down list on the worksheet, so when I try to programmatically refer to a cell for any of these options, it does not work:

    Please Login or Register  to view this content.
    So those values of Font name, font size, and dashstyle, I want the user to be able to select from a dropdown I can put in a worksheet cell. I'm sure this is just syntax, and I'm a noob trying to learn, so if there is anyone out there who can help me with this and take a few seconds to reply, I'd be most grateful.
    Last edited by avarshav; 09-16-2016 at 09:47 PM.

  2. #2
    Forum Expert
    Join Date
    09-20-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    2,278

    Re: Refer .font.name, .font.size, line.dashstyle to a cell instead of hard coding.

    Hello welcome to the forum.

    Attached is an example file of how you might apply Font, Font Size and Line Style variables from drop downs to a Text Box. Maybe you can apply this to your actual code.

    DBY
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-16-2016
    Location
    TN
    MS-Off Ver
    2010
    Posts
    3

    Re: Refer .font.name, .font.size, line.dashstyle to a cell instead of hard coding.

    Thanks, that helped, I was able to resolve the font size and outline style of my text box, the only thing I'm missing is how to get that dang font from a dropdown. Here's my latest code:

    Please Login or Register  to view this content.
    In cell N7 I have a dropdown that selects the font names that was posted in the example, but it still pukes on me. When I run the above, I get "run-time error 1004, unable to set the Name property of the Font Class". I know this has to be something easy, I'm just missing it. any advice, anyone?

  4. #4
    Registered User
    Join Date
    09-16-2016
    Location
    TN
    MS-Off Ver
    2010
    Posts
    3

    Re: Refer .font.name, .font.size, line.dashstyle to a cell instead of hard coding.

    well, i figured it out, I don't know why it didn't read directly the font name from the cell, but I had to name the font sell as a string. posting the code that work. thank you for your help.

    Please Login or Register  to view this content.
    Last edited by avarshav; 09-17-2016 at 12:11 PM.

+ 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. How to using comma style without change font & font size
    By rameshtupe in forum Excel General
    Replies: 1
    Last Post: 07-11-2013, 01:19 PM
  2. [SOLVED] Change default font and font size on COMMENTS in cells
    By Thistledown in forum Excel General
    Replies: 4
    Last Post: 11-23-2012, 09:26 AM
  3. Replies: 15
    Last Post: 05-31-2012, 10:34 AM
  4. Macro to convert several font sizes to another font size - with an exception
    By ddd in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-08-2012, 05:17 PM
  5. Replies: 3
    Last Post: 07-06-2011, 01:30 PM
  6. Replies: 5
    Last Post: 04-22-2011, 10:21 AM
  7. Dropdown list for font size, font type and number formats
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2005, 01:06 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