liammoohan
Board Regular
- Joined
- Jan 11, 2008
- Messages
- 72
I created the below for use in VB to create a jpg file which when first created output the jpg to the same location where the excel sheet is saved; now when running it creates the file to my "Documents" folder.
Can anyone advise how I can get it back to creating the file to a specific location rather than the "Documents" folder:
Can anyone advise how I can get it back to creating the file to a specific location rather than the "Documents" folder:
VBA Code:
Sub ExportABC()
Sheets("ABC").Select
Dim oWs As Worksheet
Dim oRng As Range
Dim oChrtO As ChartObject
Dim lWidth As Long, lHeight As Long
Set oWs = ActiveSheet
Set oRng = oWs.Range("B2:D50")
oRng.CopyPicture xlScreen, xlPicture
lWidth = oRng.Width
lHeight = oRng.Height
Set oChrtO = oWs.ChartObjects.Add(Left:=0, Top:=0, Width:=lWidth, Height:=lHeight)
oChrtO.Activate
With oChrtO.Chart
.Paste
.Export FileName:="ABC.jpg", Filtername:="JPG"
End With
oChrtO.Delete
End Sub
Last edited by a moderator: