Modify Macro to copy paste 0 as blank in ppt

vbanovice123

Board Regular
Joined
Apr 15, 2011
Messages
91
Hi,

I have a macro that works perfectly when copying and pasting data tables into powerpoint. However there are two manual process thatis pending automation.

A range of cells D1:G61 have values like 0, 0.0 and 0.0% . We want the macro to copy and paste these values as blank cell when pasting into ppt.

The data table range needs expansion in the width to occupy the full slide in ppt .


Thanks
Best Regards,
vbanovice123


Below is the function to copy and paste:

Public Sub copy_range_sheet_qtr(sheet As String, rngname As String)
Dim rngCopy As Range
Dim rngDest As Range
On Error Resume Next
Set rngCopy = Sheets(sheet).Range(rngname)
On Error GoTo 0
' Make sure the range is valid
If rngCopy Is Nothing Then
MsgBox "Please select a worksheet range and try again.", vbExclamation, _
"No Range Selected"
Else
Application.ScreenUpdating = False
Workbooks.Open Filename:= _
"F:\Focus\MyFolder\Copy Paste Project\OnePagers_Templates\One Pagers_yr_qtr_viewHardCopy.xlsx"
Set rngDest = ActiveWorkbook.Sheets(sheet).Range("B1").Resize(rngCopy.Rows.Count, rngCopy.Columns.Count)
rngCopy.Copy
rngDest.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
rngDest.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
rngDest.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
ActiveWorkbook.Close SaveChanges:=True
Application.CutCopyMode = True 'Clear clipboard
Application.ScreenUpdating = True
End If

End Sub




Below are the dimensions . How can I expand the width only, should I put a bigger number for sr.width? I have not played around and tested with different numbers for the width. Guess would also need to change the ht as well.

Public Function copy_range(sheet, rngname, slide, arheight, arwidth, artop, arleft, vscale)
Sheets(sheet).Select
'Cells(rowStart, columnStart).Resize(row_count, columnCount).Select
Range(rngname).Select
' Make sure a range is selected
If Not TypeName(Selection) = "Range" Then
MsgBox "Please select a worksheet range and try again.", vbExclamation, _
"No Range Selected"
Else
' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
PPApp.ActiveWindow.View.GotoSlide (slide)
' Reference active slide
Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)
' Copy the range as a picture
Selection.CopyPicture Appearance:=xlScreen, _
Format:=xlPicture
' Paste the range
PPSlide.Shapes.Paste.Select

Set sr = PPApp.ActiveWindow.Selection.ShapeRange
sr.LockAspectRatio = msoFalse
' Resize:
sr.Width = arwidth
sr.Height = arheight
sr.Top = artop
sr.Left = arleft

'sr.ScaleHeight 0.9, msoFalse
sr.ScaleWidth vscale, msoFalse
'If sr.Width > 700 Then
'sr.Width = 700
If sr.Width > 520 Then
sr.Width = 520
Else: sr.Width = 511
End If
'If sr.Height > 420 Then
'sr.Height = 420
If sr.Height > 430 Then
sr.Height = 430
Else: sr.Height = 425
End If
' Realign:
sr.Align msoAlignCenters, True
sr.Align msoAlignMiddles, True
'sr.Top = atop
If sr.Top > 90 Then
sr.Top = 90
Else
sr.Top = 80
End If
'If aleft <> 0 Then
If aleft > 60 Then
sr.Left = 60
Else
sr.Left = 50
End If
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End If
End Function
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

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