Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
How do i remove a sheet in a qlik document using a macro?
Please help me.
Best regards and thanks in advance.
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.
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!!
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
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.
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