?
Solved

Prevent Group display

Posted on 2012-03-13
6
Medium Priority
?
185 Views
Last Modified: 2012-03-14
I need Experts advice. Is a way for us not to display the vertical group (+) option when I export the attached workbook by using the "Sub moveDifFolder" module?
RemoveGroup.xls
0
Comment
Question by:Billa7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 42

Expert Comment

by:dlmille
ID: 37718298
Just add the .Rows.Ungroup method to your worksheet.

Option Explicit

Sub moveDifFolder()
Dim wkb As Workbook
Dim newWkb As Workbook
Dim wks As Worksheet
Dim oPic As Object
Dim sPath As String
Dim fName As String
Dim fPathName As String

    Set wkb = ThisWorkbook
    sPath = "C:\temp"
    With wkb.Worksheets("Data")
    Range("AT2") = "_Issued on " & Format(Now, "mm.dd.yyyy"" @ ""hhmm")
        fName = .Range("AW1") & .Range("AV1")
        .Rows.Ungroup
    End With
    
    fPathName = sPath & "\" & fName
    
    Application.DisplayAlerts = False
    
    wkb.Sheets.Copy
    
    Set newWkb = ActiveWorkbook
    
    'delete pictures
    For Each wks In newWkb.Worksheets
        For Each oPic In wks.Pictures
            oPic.Delete
        Next oPic
    Next wks
            
    'clear K:Q in Data sheet
    Set wks = newWkb.Worksheets("Data")
    'wks.Range("K:Q").Clear
    
    'Call RemoveAllMacros(newWkb)
    'Save the workbook
    
    newWkb.SaveAs Filename:=fPathName & ".xls", FileFormat:=xlExcel8
    newWkb.Close
    
    
    MsgBox "Process Complete!"
End Sub

Open in new window

0
 
LVL 42

Expert Comment

by:dlmille
ID: 37718301
So, for row group removal:

Wks.Rows.Ungroup

and for column group removal:

Wks.Columns.Ungroup

Cheers,

Dave
0
 

Author Comment

by:Billa7
ID: 37718602
Hi Dave,

The group removal need to be done at export file, not the source. Please assist.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Billa7
ID: 37719290
Hi Dave,

I have tried to copy "Wks.Rows.Ungroup" at exported wb but it shows as:

Invalid or unqualified reference.


Here's the line that I've tested:

Next wks
           
    'clear K:Q in Data sheet
    Set wks = newWkb.Worksheets("Data")
    .Rows.Ungroup
    'wks.Range("K:Q").Clear
0
 
LVL 42

Accepted Solution

by:
dlmille earned 2000 total points
ID: 37720905
The wks.  in my example is just the variable that holds the worksheet object where you want to make the change.

You were close, but need to reference the wks object in your statement (in the previous post, you were doing a With, so I used .Rows.Ungroup.  In this instance, we can just reference the worksheet object directly (and we could have, in the prior post, as well).

Here's your modified code (See added line 36):
Option Explicit

Sub moveDifFolder()
Dim wkb As Workbook
Dim newWkb As Workbook
Dim wks As Worksheet
Dim oPic As Object
Dim sPath As String
Dim fName As String
Dim fPathName As String

    Set wkb = ThisWorkbook
    sPath = "C:\temp"
    With wkb.Worksheets("Data")
    Range("AT2") = "_Issued on " & Format(Now, "mm.dd.yyyy"" @ ""hhmm")
        fName = .Range("AW1") & .Range("AV1")
    End With
    
    fPathName = sPath & "\" & fName
    
    Application.DisplayAlerts = False
    
    wkb.Sheets.Copy
    
    Set newWkb = ActiveWorkbook
    
    'delete pictures
    For Each wks In newWkb.Worksheets
        For Each oPic In wks.Pictures
            oPic.Delete
        Next oPic
    Next wks
            
    'clear K:Q in Data sheet
    Set wks = newWkb.Worksheets("Data")
    wks.Rows.Ungroup
    'wks.Range("K:Q").Clear
    
    'Call RemoveAllMacros(newWkb)
    'Save the workbook
    
    newWkb.SaveAs Filename:=fPathName & ".xls", FileFormat:=xlExcel8
    newWkb.Close
    
    
    MsgBox "Process Complete!"
End Sub

Open in new window


Dave
0
 

Author Closing Comment

by:Billa7
ID: 37723145
Thanks a lot Dave
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question