+ Reply to Thread
Results 1 to 9 of 9

VBA to access pop up save as in IE

Hybrid View

  1. #1
    Forum Expert Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,429

    VBA to access pop up save as in IE

    Hi All

    Me again lol....
    How does one access the pop up save as through vba...
    My code clicks a button "capture to file" then the pop up appears...No element to get...
    Set obj = IE.document.getElementById("btnChartCaptureImage"): obj.Click
    Untitled.png


    If the above proves to difficult which web trolling has shown then perhaps vba to:

    open paint application
    paste
    save as

    cause this code...copies the chart to clipboard...
    Set obj = IE.document.getElementById("btnChartCopyToClipboard"): obj.Click
    Last edited by Sintek; 02-28-2018 at 02:07 PM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,935

    Re: VBA to access pop up save as in IE

    Send keys maybe. As far as I'm aware, there isn't API built in to work with save as menu in IE.

    Can you trace in developer tool what "btnChartCopyToClipboard" is doing?

    Or if you just want to capture image, you could do it via freefile() method I'd imagine. But I'd need to see source HTML code for the page.
    Can you upload text file with entire HTML code pasted in? (In IE, while you have the page active, right click and see source, copy entire code and paste).
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Expert Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,429

    Re: VBA to access pop up save as in IE

    Hey there again CK76

    Have attached Source code from page...I am assuming the highlighted part in image is what I need...
    Untitled.png


    Found this link but does not quite solve...Sticks at Dialogue box
    https://stackoverflow.com/questions/...from-excel-vba
    Attached Files Attached Files
    Last edited by Sintek; 03-01-2018 at 07:43 AM.

  4. #4
    Forum Expert Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,429

    Re: VBA to access pop up save as in IE

    Hey guys...
    As an alternative perhaps...I have code that copies to clipboard, opens paint and pastes chart...

    Need the code to save as from there to specific folder...Any ideas..
    Set obj = IE.document.getElementById("btnChartCopyToClipboard"): obj.Click
             
    ' Paste to paint and save
    Path = "C:\Windows\system32\mspaint.exe"
    MyAppID = Shell(Path, 1)
    Application.Wait (Now + TimeValue("0:00:05"))
    AppActivate (MyAppID)
    Application.Wait (Now + TimeValue("0:00:05"))
    Application.SendKeys "^v", True
    Application.SendKeys "^s", True 'This opens up the save dialogue box
    ' Need code here to save As Thisworkbook.Path & "/" & "Linechart.png"

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,935

    Re: VBA to access pop up save as in IE

    Hmm, no need to use MS paint. Paste copied item into excel worksheet using following (it will create shape).
    After you copy img to clipboard.
    ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
            False
    Then combine it with Chart.Export method. Something like below.
    Dim myPic As Shape
    
    ActiveSheet.PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:= _
            False
    Set myPic = ActiveSheet.Shapes(1)
    myPic.Copy
        With ActiveSheet.ChartObjects.Add(myPic.Left, myPic.Top, myPic.Width, myPic.Height)
            .Name = "Blah"
            .Activate
        End With
    ActiveChart.Paste
        With ActiveSheet.ChartObjects("Blah")
            .Chart.Export ThisWorkbook.Path & "\Test" & ".png", "PNG"
            .Delete
        End With
    myPic.Delete
    Last edited by CK76; 03-01-2018 at 10:19 AM.

  6. #6
    Forum Expert Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,429

    Re: VBA to access pop up save as in IE

    Hi CK76

    Thanks for response...This code renders a border paste...Not the chart...I know that it is the chart that gets copied because when pasting into paint, the chart shows up...Any ideas?
    ActiveSheet.PasteSpecial Format:="HTML", link:=False, DisplayAsIcon:=False
    Edit
    Not to worry...Changed HTML to Bitmap
    Last edited by Sintek; 03-01-2018 at 11:43 AM.

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,935

    Re: VBA to access pop up save as in IE

    Ah, right. I copied image with transparent background from Google Image search for testing.
    That one need to be pasted as "HTML" to have transparent background. Forgot about that.

    Those images when pasted as "Bitmap" will have black background instead of transparent.
    0.JPG

  8. #8
    Forum Expert Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,429

    Re: VBA to access pop up save as in IE

    I am a very happy chappy right now...Thanks CK76.
    Works very well...
    ActiveSheet.PasteSpecial Format:="Bitmap", link:=False, DisplayAsIcon:=False
    Set Pic = ActiveSheet.Shapes("Picture 1")
    Pic.Copy: Charts.Add
    With ActiveSheet.ChartObjects.Add(Pic.Left, Pic.Top, Pic.Width, Pic.Height)
       .Name = "LineChart"
       .Activate
    End With
    ActiveChart.Paste
    With ActiveSheet.ChartObjects("LineChart")
        .Chart.Export ThisWorkbook.Path & "\" & "LineChart.png"
        .Delete
    End With
    Application.DisplayAlerts = False
    Sheets("Chart1").Delete
    Application.DisplayAlerts = True
    Pic.Delete

  9. #9
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,935

    Re: VBA to access pop up save as in IE

    You are welcome and thanks for the rep

+ 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. Excel sum up data and save in Access
    By Uruzu5 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-27-2015, 06:03 AM
  2. Save data from excel to Access in another system
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2011, 12:17 PM
  3. Save data From Excel Into Access
    By sibalamit in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-05-2010, 12:45 PM
  4. Open Access File & Save Copy As Different Name
    By pr4t3ek in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-19-2008, 06:49 PM
  5. save excel in access
    By jagguy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-29-2007, 03:21 AM
  6. [SOLVED] how to save to Access
    By Medhat in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2005, 05:19 PM
  7. Replies: 2
    Last Post: 03-03-2005, 12:06 AM

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