Brendan L
Brendan L

Reputation: 1

Excel Get current user name VBA help needed for script

I have a Filemaker Pro runtime DB that exports reports to Excel then opens in PDF, there is no problems running this on my machine but.....when a customer loads it onto there machine the VBA code (Current Username) needs to change. One big hurdle for me is to be able to distribute the Excel forms with my solution and have Excel know the different User name. So below is part of my VBA, I need to be able to change the SEAQ(username) to the Current Username.....export to Location is documents, I don't need to change that part.

ActiveWorkbook.UpdateLink Name:= _
    "C:\Users\seaq\Desktop\LAB 17025\Forms\Particle Distribution\PD FM Exported.xlsx" _
    , Type:=xlExcelLinks

Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\seaq\Desktop\LAB 17025\Forms\Particle Distribution\Particle Dist Customer Report.pdf" _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True

Upvotes: 0

Views: 275

Answers (1)

Tim Williams
Tim Williams

Reputation: 166885

E.g.

ActiveWorkbook.UpdateLink Name:= _
   "C:\Users\" & Environ("Username") & _
   "\Desktop\LAB 17025\Forms\Particle Distribution\PD FM Exported.xlsx", _
   Type:=xlExcelLinks

Upvotes: 1

Related Questions