+ Reply to Thread
Results 1 to 7 of 7

Stuck with SendKeys, but doens't work

  1. #1
    Registered User
    Join Date
    01-29-2024
    Location
    Amsterdam
    MS-Off Ver
    365
    Posts
    31

    Stuck with SendKeys, but doens't work

    I'm having reports with graphic elements (imported SVG pictures) in it. The problem is that the reports are growing to substantial sizes. The empty report Excel sheet is 57Kb, the imported SVG files are all between 30-60Kb. When I place about 15 SVG files, my XLSX file grows to 15Mb or larger. I am using Microsoft� Excel� for Microsoft 365 MSO (Version 2406 Build 16.0.17723.20000) 64-bit (Insider version)

    If I use the option in Excel (after selecting the graphic) Graphic Format > Convert to Shape, my file shrunk below 1Mb again.

    As far as I know there is no VBA method to choose this option, so I'm stuck with the only alternative, SendKeys. The shortcut keys to select this command is ALT J G C 1 in that order.

    I created a macro for this purpose. However, this does not seem to work. The selected keys are sent to the VBA application and not to the worksheet with the picture in it.

    A simple example will illustrate this

    Please Login or Register  to view this content.
    When I select this macro from the workbook (run macro) it works perfectly. But I want to integrate it in a larger macro that generates about 30 different reports every month. How can I make sure that the sendkeys are send to the workbook with the graphic element in it?

    Art
    Last edited by dxfoxd; 06-03-2024 at 05:52 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Stuck with SendKeys, but doens't work

    I personally have a strong aversion to sendkeys, I'll see if I can help. i'm using 2012 not 365 but that shouldn/t he a problem
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,472

    Re: Stuck with SendKeys, but doens't work

    Try this

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,937

    Re: Stuck with SendKeys, but doens't work

    @Andy: but then you're in edit mode.
    @dxfoxd: what is exactly what you want to achieve? Resize? Placement?

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,472

    Re: Stuck with SendKeys, but doens't work

    For me the code adds a svg image and converts to a shape.

    The ribbon of the selected image changes from Graphics Format to Shape Format.

    It does not appear to be in 'edit' mode, as you would get if it was a freeform shape being edited.

  6. #6
    Registered User
    Join Date
    01-29-2024
    Location
    Amsterdam
    MS-Off Ver
    365
    Posts
    31

    Re: Stuck with SendKeys, but doens't work

    Thx Andy, this is exactly what I was trying to achieve. Bt only adding this line of code to my macro, the file size of the report that is created decreased from 15.4Mb to 423Kb. Quite a difference huh!

    Art.

  7. #7
    Registered User
    Join Date
    01-29-2024
    Location
    Amsterdam
    MS-Off Ver
    365
    Posts
    31

    Re: Stuck with SendKeys, but doens't work

    My objective is to decrease the file size by not including the images as pictures in the file. By changing the imported SVG files to a speadsheet drawing, the file size will decrease significantly because the inserted images are not saved as a PNG file.

+ 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. why doesn't SendKeys work consistently?
    By crimsonkng in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-13-2022, 12:58 AM
  2. partial HLOOKUP doens't seem to work
    By willmatthews99 in forum Excel General
    Replies: 8
    Last Post: 08-15-2019, 04:48 AM
  3. Consecutive Sendkeys commands won't work
    By PedalSteeler in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2015, 09:38 AM
  4. I Can't get SHOWDATAFORM and sendkeys to work together?
    By jegentry in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-03-2014, 03:52 AM
  5. Stuck at work and stuck on a count function
    By gregfetzer in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-24-2012, 12:47 AM
  6. Sendkeys doesn't work on my laptop with Vista
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-26-2010, 07:24 PM
  7. [SOLVED] Application.SendKeys won't work with Remote Desktop????
    By WildIrish in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2005, 11:06 AM

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