excel_learnerz
Board Regular
- Joined
- Dec 12, 2018
- Messages
- 73
Hello all,
I was hoping one of the knowledgeable people here might want to lend some wisdom to help me with my macro
The below macro does work (I am new to VBA so apologies in advance for the bad code, I am sure there are nicer ways to write it)
the macro picks up a value and whichever currency it is it saves a sheet called "quote" to sharepoint in a folder with company name
That's all well and good but in the folder path I have "C:\users\user_1" as part of it. I have SP mapped to my network so the macro works for me since I am user_1 but how can I change this to get it to work for anyone who opens the workbook to generate a quote and not just me, I am not sure how the SP url, I tried but it didn't work or some other way
Thanks in advance
Sub Quote_SP()
Dim FSO
Dim USDFolder As String
Dim EURFolder As String
Dim UKFolder As String
Dim USDPath As String
Dim EURPath As String
Dim UKPath As String
USDPath = "C:\Users\user_1\company\Sales Team - Documents\Quotes\Test_USD"
EURPath = "C:\Users\user_1\company\Sales Team - Documents\Quotes\Test_EUR"
UKPath = "C:\Users\user_1\company\Sales Team - Documents\Quotes\Test_UK"
USDFolder = USDPath & ActiveSheet.Range("B2").Value
EURFolder = EURPath & ActiveSheet.Range("B2").Value
UKFolder = UKPath & ActiveSheet.Range("B2").Value
ChDir "C:\Users\user_1\company\Sales Team - Documents\Quotes"
If ActiveSheet.Range("B3").Value = "$ Dollar" Then
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not FSO.FolderExists(USDFolder) Then
FSO.CreateFolder (USDFolder)
End If
With Sheets("Quote")
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=USDFolder & "" & ActiveSheet.Range("B2").Value & " " & Format(Now, "mmm-dd-yyyy hh-mm") & " " & ActiveSheet.Range("B14").Value & " Quote.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With
ElseIf ActiveSheet.Range("B3").Value = "£ Sterling" Then
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not FSO.FolderExists(UKFolder) Then
FSO.CreateFolder (UKFolder)
End If
With Sheets("Quote")
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=UKFolder & "" & ActiveSheet.Range("B2").Value & " " & Format(Now, "mmm-dd-yyyy hh-mm") & " " & ActiveSheet.Range("B14").Value & " Quote.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With
ElseIf ActiveSheet.Range("B3").Value = "€ Euro" Then
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not FSO.FolderExists(EURFolder) Then
FSO.CreateFolder (EURFolder)
End If
With Sheets("Quote")
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=EURFolder & "" & ActiveSheet.Range("B2").Value & " " & Format(Now, "mmm-dd-yyyy hh-mm") & " " & ActiveSheet.Range("B14").Value & " Quote.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With
End If
End Sub
I was hoping one of the knowledgeable people here might want to lend some wisdom to help me with my macro
The below macro does work (I am new to VBA so apologies in advance for the bad code, I am sure there are nicer ways to write it)
the macro picks up a value and whichever currency it is it saves a sheet called "quote" to sharepoint in a folder with company name
That's all well and good but in the folder path I have "C:\users\user_1" as part of it. I have SP mapped to my network so the macro works for me since I am user_1 but how can I change this to get it to work for anyone who opens the workbook to generate a quote and not just me, I am not sure how the SP url, I tried but it didn't work or some other way
Thanks in advance
Sub Quote_SP()
Dim FSO
Dim USDFolder As String
Dim EURFolder As String
Dim UKFolder As String
Dim USDPath As String
Dim EURPath As String
Dim UKPath As String
USDPath = "C:\Users\user_1\company\Sales Team - Documents\Quotes\Test_USD"
EURPath = "C:\Users\user_1\company\Sales Team - Documents\Quotes\Test_EUR"
UKPath = "C:\Users\user_1\company\Sales Team - Documents\Quotes\Test_UK"
USDFolder = USDPath & ActiveSheet.Range("B2").Value
EURFolder = EURPath & ActiveSheet.Range("B2").Value
UKFolder = UKPath & ActiveSheet.Range("B2").Value
ChDir "C:\Users\user_1\company\Sales Team - Documents\Quotes"
If ActiveSheet.Range("B3").Value = "$ Dollar" Then
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not FSO.FolderExists(USDFolder) Then
FSO.CreateFolder (USDFolder)
End If
With Sheets("Quote")
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=USDFolder & "" & ActiveSheet.Range("B2").Value & " " & Format(Now, "mmm-dd-yyyy hh-mm") & " " & ActiveSheet.Range("B14").Value & " Quote.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With
ElseIf ActiveSheet.Range("B3").Value = "£ Sterling" Then
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not FSO.FolderExists(UKFolder) Then
FSO.CreateFolder (UKFolder)
End If
With Sheets("Quote")
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=UKFolder & "" & ActiveSheet.Range("B2").Value & " " & Format(Now, "mmm-dd-yyyy hh-mm") & " " & ActiveSheet.Range("B14").Value & " Quote.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With
ElseIf ActiveSheet.Range("B3").Value = "€ Euro" Then
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not FSO.FolderExists(EURFolder) Then
FSO.CreateFolder (EURFolder)
End If
With Sheets("Quote")
.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=EURFolder & "" & ActiveSheet.Range("B2").Value & " " & Format(Now, "mmm-dd-yyyy hh-mm") & " " & ActiveSheet.Range("B14").Value & " Quote.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End With
End If
End Sub