LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Export sheets as JPEG files through a dialog box (Problems)

Hello,

I have a problem with some code I have and was hoping for some
assistance.

The code below is supose to do the following:
1. Create a dialog box in the current workbook (Centara Feasibility
Study)
2. I select the sheets I would like to export to another (new)
workbook in JPEG format by selecting the checkboxes in the dialog box.
3. Once i press OK the following is supose to happen:
A. A new workbook is created (Centara Feasibility Copy 1.xls)
B. Sheets on the original workbook are copied (if the dialog
check box for that sheet was selected) and are then pasted in the new
workbook as JPEG files.
C. Just prior to this the macro is supose to add a new worksheet
in the 'Copy 1' workbook and rename the sheet (the new name for the
sheet is supose to be the same name as the sheet where the original
was copied from).

Thats it...except for a bug I cannot for the life of me figure out
what to do.
The bug is somewhere in the selecting of the sheets to copy and the
nameing of the new worksheets.

Any help on this would be appreciated.
Thanks
Tim


Sub Export_Sheets()

Dim mypass As String

Dim i As Integer
Dim TopPos As Integer
Dim SheetCount As Integer
Dim PrintDlg As DialogSheet
Dim CurrentSheet As Worksheet
Dim CB As CheckBox
Application.ScreenUpdating = False

' Check for protected workbook
If ActiveWorkbook.ProtectStructure Then
MsgBox "Workbook is protected.", vbCritical
Exit Sub
End If

' Add a temporary dialog sheet
Set CurrentSheet = ActiveSheet
Set PrintDlg = ActiveWorkbook.DialogSheets.Add

SheetCount = 0

' Add the checkboxes
TopPos = 40
For i = 1 To ActiveWorkbook.Worksheets.Count
Set CurrentSheet = ActiveWorkbook.Worksheets(i)
' Skip empty sheets sheets
If Application.CountA(CurrentSheet.Cells) = 0 Then
SheetCount = SheetCount + 1
PrintDlg.CheckBoxes.Add 78, TopPos, 150, 16.5
PrintDlg.CheckBoxes(SheetCount).text = _
CurrentSheet.Name
If Worksheets(i).Visible < xlSheetVisible Then
PrintDlg.CheckBoxes(SheetCount).Value = True
End If
TopPos = TopPos + 13
End If
Next i

' Move the OK and Cancel buttons
PrintDlg.Buttons.Left = 240

' Set dialog height, width, and caption
With PrintDlg.DialogFrame
.Height = Application.Max _
(68, PrintDlg.DialogFrame.Top + TopPos - 34)
.Width = 230
.Caption = "Select sheets to export"
End With

' Change tab order of OK and Cancel buttons
' so the 1st option button will have the focus
PrintDlg.Buttons("Button 2").BringToFront
PrintDlg.Buttons("Button 3").BringToFront

' Display the dialog box
CurrentSheet.Activate
Application.ScreenUpdating = True
If SheetCount < 0 Then
If PrintDlg.Show Then
Workbooks.Add
ChDir "C:\Documents and Settings\Em\Desktop"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\Em\Desktop\Centara
Feasibility Copy 1.xls", _
ReadOnlyRecommended:=False, CreateBackup:=False
For Each CB In PrintDlg.CheckBoxes
Worksheets(CB.Caption).Activate
If CB.Value = xlOn Then
Windows("Centara Feasibility Study
Tool.xls").Activate
Sheets(CB.SheetCount.text).Select
Range("A1:X163").Select
Range("A1:X163").Copy
Windows("Centara Feasibility Copy 1.xls").Activate
Sheets.Add
Sheets(ActiveSheet).Name =
PrintDlg.CheckBoxes(SheetCount).text
Range("A1").Select
ActiveSheet.Pictures.Paste.Select
Selection.ShapeRange.ZOrder msoSendToBack
Range("A1").Select
Application.CutCopyMode = False
Else
ActiveSheet.Visible = xlSheetVisible
End If
Next CB
End If
Else
MsgBox "All worksheets are empty."
End If

' Delete temporary dialog sheet (without a warning)
Application.DisplayAlerts = False
PrintDlg.Delete

' Reactivate original sheet
Cover.Activate
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
export sheets to multiple new files Tanya Excel Discussion (Misc queries) 8 April 20th 09 10:00 PM
Chart export - high resolution, no gif or jpeg [email protected] Charts and Charting in Excel 3 March 11th 09 02:24 AM
Problems Coping and moving sheets between files Excell 2007 [email protected] Excel Discussion (Misc queries) 2 November 23rd 07 04:37 PM
Create 50,000 drawings in Excel and export to jpeg OcalaGalToo Excel Discussion (Misc queries) 0 July 18th 06 02:44 PM
Set parameters for JPEG export by VBA (to improve quality) rhmd Excel Programming 1 September 22nd 03 12:21 AM


All times are GMT +1. The time now is 01:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"