Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Deleting a Sheet with a macro

Hello,

How do i remove a sheet in a qlik document using a macro?

Please help me.

Best regards and thanks in advance.

14 Replies
Not applicable
Author

Sub Activate_Discounturi
'---------------------
ACTIVEDOCUMENT.CLEARALL
ActiveDocument.Sheets("Discounturi").Activate
End sub


sub CRISTI
ActiveDocument.clearall
ActiveDocument.Fields("DISTRIBUITOR").Select "DECORA"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "DECORV"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "LIPOTE"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "RAVALE"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "DURABI"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "MURAEX"
ActiveDocument.reducedata
ActiveDocument.saveas "C:\DE TRIMIS LA RSM\CRISTIM.qvw"
call sendmail("name@domain.ro","name_1@domain.ro","raport_vanzari","hello","C:\DE TRIMIS LA RSM\CRISTIM.qvw")
end sub

Public Function SendMail(ByVal From, ByVal SendTo, ByVal Subject, ByVal Body, ByVal Attachment)

Dim objOutlook
Dim objMessage
set objOutlook = CreateObject("Outlook.Application")
set objMessage = objOutlook.CreateItem(0)
objMessage.Subject = Subject

objMessage.To = SendTo
objMessage.Body = Body
If (Not "" = Attachment) Then
objMessage.Attachments.Add(Attachment)
End If

objMessage.send

End Function

this are my macros for now. For macro CRISTI i have a button. In this macro i need to put a function to hide the sheet where is this button, before saving i think.

Not applicable
Author

Ok,

You just have to do the following:

sub CRISTI

call hide <- for hidding the sheet


ActiveDocument.clearall
ActiveDocument.Fields("DISTRIBUITOR").Select "DECORA"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "DECORV"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "LIPOTE"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "RAVALE"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "DURABI"
ActiveDocument.Fields("DISTRIBUITOR").ToggleSelect "MURAEX"
ActiveDocument.reducedata
ActiveDocument.saveas "C:\DE TRIMIS LA RSM\CRISTIM.qvw"
call sendmail("name@domain.ro","name_1@domain.ro","raport_vanzari","hello","C:\DE TRIMIS LA RSM\CRISTIM.qvw")

call hide <- again for showing the sheet
ActiveDocument.saveas "C:\DE TRIMIS LA RSM\CRISTIM.qvw"
end sub

that's all!!

Not applicable
Author

Hi Miguel,

Nice solution for hiding/showing sheets!

I can get your example to work ok on a new qvw but not on an existing one I'm working on that was created by another user.

Is there some setting somewhere that overides the conditional show sheet option?

Many thanks,
Phil

[edited by: philryan at 6:06 (GMT -5) on to, jan 21 2010] I had to uncheck the 'show all sheets and objects' option in the document security tab!
Not applicable
Author

Hi Philryan,

Do you have to logging in to the existing file? in this case, is your account privileges like user or admin? besides, are you using a Qlikview personal edition?

Best regards.

Not applicable
Author

Hi Miguel,

Thanks for the reply, I managed to get it to work in the end... in the document securities tab the option 'show all sheets and objects' option was checked, as soon as I unchecked the option it worked fine 🐵

Thanks,
Phil