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'
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,785
Office Version
  1. 365
Platform
  1. Windows
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.
 

niccoflo

New Member
Joined
Jun 11, 2016
Messages
13
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
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
48,400
Office Version
  1. 365
Platform
  1. Windows
Would this work for you to automatically determine the desktop path?

VBA Code:
Dim sDeskTopPath As String

sDeskTopPath = Environ("USERPROFILE") & "\Desktop"
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,785
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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.
 

niccoflo

New Member
Joined
Jun 11, 2016
Messages
13
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
 

Watch MrExcel Video

Forum statistics

Threads
1,128,153
Messages
5,628,997
Members
416,358
Latest member
grsaltzman

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
Top