Insert logo only one time

niccoflo

New Member
Joined
Jun 11, 2016
Messages
13
Hello, I have a question which I did not find an answer for n any forum.

I am creating a company-wide macro that allows people to format a blank sheet as per company standard. This involves inserting a logo (picture) on the top left of the sheet. This picture will be saved on their desktop.

HOWEVER, I don't want the macro to ask the user to Browse the picture from the desktop EVERY TIME they run the formatting macro, but ONLY THE FIRST TIME.

In other words:

FIRST TIME THE USER RUNS THE MACRO:

- VBA code will ask the user to browse the picture
- The sheet will be formatted with the logo selected by the user

NEXT TIME THE USER RUNS THE MACRO:

- The sheet will be formatted with the logo which can be found at the same path as the first time the user ran the macro

I hope it's clear

Thanks
Niccolo'
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi, and Welcome to Mr. Excel!

Surely, if the logo picture's always on each user's desktop, then the path to the picture's always the same, and there's no need to run code asking the user to select the picture; just hard-code the path into the code.
 
Upvote 0
Hi Sykes, true, the problem is that the path to get to the picture is always different (depending on the user). For example

For me it is: "C:\Users\nflore02\OneDrive - Org\Desktop\Logo.jpg"
For you it might be: "C:\Users\sykes\OneDrive - Org\Desktop\Logo.jpg",

and so on...that is why I am asking the question. Once people save the picture on their desktop, the first time they run the macro they go and browse to the picture, but from the second time onwards, the path should be saved, therefore they should not go and pick the picture again!

Let me know if it makes sense
 
Upvote 0
Would this work for you to automatically determine the desktop path?

VBA Code:
Dim sDeskTopPath As String

sDeskTopPath = Environ("USERPROFILE") & "\Desktop"
 
Upvote 0
No need to state the username as a string - just use "Application.UserName" thus:

"C:\Users\" & Application.UserName & "\nflore02\OneDrive - Org\Desktop\Logo.jpg"

Edit - removed one double quote mark from the end of the string.
 
Upvote 0
No need to state the username as a string - just use "Application.UserName" thus:

"C:\Users\" & Application.UserName & "\nflore02\OneDrive - Org\Desktop\Logo.jpg"

Edit - removed one double quote mark from the end of the string.

This does not work as "Application.UserName" is not the same as my User
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,973
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top