VBA Excel Adding pictures to a worksheet

0 votes

I discovered some code that enables the user to select which image should be added to a worksheet. Instead, I was hoping it would select and insert a certain image—more precisely, the corporate logo. Here is the key:

PicLocation = Application.GetSaveAsFilename("C:\Work\test_Project\", "CA_Value_AVM, *.jpg", 1)
If PicLocation <> "" Then
    ActiveSheet.Pictures.Insert(PicLocation).Select
Else
    Exit Sub
End If

This code is executed when a button is clicked. The user clicks it and then the path "C:\Work\test_Project\" is opened and the user has to click the picture. I need this to change so that the user doesn't click anything.

Jan 3, 2023 in Others by Kithuzzz
• 38,010 points
331 views

1 answer to this question.

0 votes

It should work as:

ActiveSheet.Pictures.Insert("C:\Work\test_Project\myjpgfile.jpg").Select

As that's all the function is returning anyway.

answered Jan 3, 2023 by narikkadan
• 63,720 points

Related Questions In Others

0 votes
1 answer

Select data that meet criteria from a table, adding it to a combobox in userform VBA Excel

Fill Combo Box With Matches Sub GetSourceAcc() ...READ MORE

answered Mar 26, 2023 in Others by Kithuzzz
• 38,010 points
592 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
664 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,670 points
876 views
0 votes
1 answer

Excel VBA : HOW TO PRINT THE TEXT IN A CELL (like Wrap Text)

Use a LineFeed character to create a ...READ MORE

answered Oct 27, 2022 in Others by narikkadan
• 63,720 points
875 views
0 votes
1 answer

Convert image (jpg, png, jpeg) to base64

Try this - it will perform the ...READ MORE

answered Sep 24, 2022 in Others by narikkadan
• 63,720 points
850 views
0 votes
1 answer

How to insert a picture into Excel at a specified cell position with VBA

Try this: With xlApp.ActiveSheet.Pictures.Insert(PicPath) With ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,720 points
2,225 views
0 votes
1 answer

Trying to create an enclosing bookmark after pasting a picture from Excel into Word using VBA

Try this: Sub IMPORT_TO_WORD() Dim ws1 As Worksheet, ws2 ...READ MORE

answered Oct 30, 2022 in Others by narikkadan
• 63,720 points
732 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
996 views
0 votes
1 answer

Excel-VBA - How to identify Target range (more than 1 cell) is deleted in a Worksheet_Change function?

You misunderstand the purpose of the function ...READ MORE

answered Sep 23, 2022 in Others by narikkadan
• 63,720 points
3,336 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP