Here's "CorelDrawFix.txt". the program's help file:
Code:
	CorelDrawFix

For some ".CDR" files, CorelDraw will display a messagebox saying
"Error reading" [filename] "file".
This problem has been seen to occur with files containing links
between pages (links defined under the "internet" tab of the
properties dialog). This program might not fix problems related to
any other type of content.
 Although the author has had no problems with files fixed by this
program, this program does not guarantee a perfect fix for the files.
It can certainly give you the chance to open files which you otherwise
couldn't so you can copy the contents to another file.

This program deletes all bytes between byte 22 (&H16) and the
occurrence of "LIST" just preceding "INFOIKEY", then adjusted the
length value, at offset 4, which must be equal to FileLength - 8

0000:  52 49 46 46		"RIFF"
0004:  F2 4B 00 00		00004BF2 = FileLength - 8
0008:  43 44 52 38 76 72 73 6E	"CDR8vrsn"


	Example file before fixing:
---------------------------------------------------------------------------
Offset 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
---------------------------------------------------------------------------
0000:  52 49 46 46 C8 9B 00 00 43 44 52 38 76 72 73 6E  RIFFÈ›..CDR8vrsn
0010:  02 00 00 00 20 03 75 72 6C 20 52 00 00 00 4C 49  .... .url R...LI
0020:  53 54 4A 00 00 00 75 72 6C 6C 75 72 6C 73 06 00  STJ...urllurls..
0030:  00 00 5F 50 41 47 45 36 75 72 6C 73 06 00 00 00  .._PAGE6urls....
0040:  5F 50 41 47 45 35 75 72 6C 73 06 00 00 00 5F 50  _PAGE5urls...._P
0050:  41 47 45 33 75 72 6C 73 06 00 00 00 5F 50 41 47  AGE3urls...._PAG
0060:  45 34 75 72 6C 73 06 00 00 00 5F 50 41 47 45 32  E4urls...._PAGE2
0070:  4C 49 53 54 14 01 00 00 49 4E 46 4F 49 4B 45 59  LIST....INFOIKEY
0080:  80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  €...............


	Example file after fixing:
---------------------------------------------------------------------------
Offset 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
---------------------------------------------------------------------------
0000:  52 49 46 46 6E 9B 00 00 43 44 52 38 76 72 73 6E  RIFFn›..CDR8vrsn
0010:  02 00 00 00 20 03 4C 49 53 54 14 01 00 00 49 4E  .... .LIST....IN
0020:  46 4F 49 4B 45 59 80 00 00 00 00 00 00 00 00 00  FOIKEY€.........
0030:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0040:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0050:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0060:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0070:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0080:  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Code:
'**************************************
'   "CorelDrawFix.bas"

'Fixes some CorelDraw (.CDR) files.
'Only tested on files from version 8.

'Public domain 2009, by TheirCorp
'**************************************

#Compile Exe "CorelDrawFix.exe"
#Dim All
#Register All

'**************************************

'if you have "pbforms.inc", you can use a fixed-width font for viewing the help file
'%UseFont	= 1

'**************************************
' Created by inClean v1.25, 02-01-2009, 11:25:40
' Press Help-button for some useful information and tips.

'-----------------------------------------------------------------
' Equates:  51
'-----------------------------------------------------------------

%WINAPI				   = 1
%TRUE				   = 1
%FALSE				   = 0
%WM_USER			   = &H400
%LF_FACESIZE		   = 32
%MAX_PATH			   = 260		 ' max. length of full pathname
%ANSI_CHARSET		   = 0
%FF_DONTCARE		   = 0			 ' Don't care or don't know.
%FW_DONTCARE		   = 0
%FW_NORMAL			   = 400
%LOGPIXELSY			   = 90			 ' Logical pixels/inch in Y
%WM_DESTROY			   = &H2
%WM_SETFONT			   = &H30
%WM_HELP			   = &H53
%WM_NCACTIVATE		   = &H86
%WM_INITDIALOG		   = &H110
%WM_COMMAND			   = &H111
%WM_DROPFILES		   = &H233
%WS_POPUP			   = &H80000000
%WS_CHILD			   = &H40000000
%WS_VISIBLE			   = &H10000000
%WS_CLIPSIBLINGS	   = &H04000000
%WS_CAPTION			   = &H00C00000	 ' WS_BORDER OR WS_DLGFRAME
%WS_BORDER			   = &H00800000
%WS_DLGFRAME		   = &H00400000
%WS_VSCROLL			   = &H00200000
%WS_SYSMENU			   = &H00080000
%WS_TABSTOP			   = &H00010000
%WS_MINIMIZEBOX		   = &H00020000
%WS_EX_ACCEPTFILES	   = &H00000010
%WS_EX_CLIENTEDGE	   = &H00000200
%WS_EX_LEFT			   = &H00000000
%WS_EX_LTRREADING	   = &H00000000
%WS_EX_RIGHTSCROLLBAR  = &H00000000
%WS_EX_CONTROLPARENT   = &H00010000
%HWND_DESKTOP		   = 0
%ES_LEFT			   = &H0&
%ES_MULTILINE		   = &H4&
%ES_AUTOHSCROLL		   = &H80&
%ES_WANTRETURN		   = &H1000&
%BS_TEXT			   = &H0&
%BS_PUSHBUTTON		   = &H0&
%BS_DEFPUSHBUTTON	   = &H1&
%BS_CENTER			   = &H300&
%BS_VCENTER			   = &HC00&
%BN_CLICKED			   = 0
%DS_3DLOOK			   = &H0004&
%DS_NOFAILCREATE	   = &H0010&
%DS_SETFONT			   = &H0040&	 ' User specified font for Dlg controls
%DS_MODALFRAME		   = &H0080&	 ' Can be combined with WS_CAPTION
%DM_SETDEFID		   = %WM_USER + 1

'-----------------------------------------------------------------
' TYPE and UNION structures:  1
'-----------------------------------------------------------------

Type LOGFONT
	lfHeight		  As Long
	lfWidth			  As Long
	lfEscapement	  As Long
	lfOrientation	  As Long
	lfWeight		  As Long
	lfItalic		  As Byte
	lfUnderline		  As Byte
	lfStrikeOut		  As Byte
	lfCharSet		  As Byte
	lfOutPrecision	  As Byte
	lfClipPrecision	  As Byte
	lfQuality		  As Byte
	lfPitchAndFamily  As Byte
	lfFaceName		  As Asciiz * %LF_FACESIZE
End Type

'-----------------------------------------------------------------
' Declared Functions:  11
'-----------------------------------------------------------------

Declare Function CreateFontIndirect Lib "GDI32.DLL" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Dword
Declare Function DeleteObject Lib "GDI32.DLL" Alias "DeleteObject" (ByVal hObject As Dword) As Long
Declare Function DragQueryFile Lib "SHELL32.DLL" Alias "DragQueryFileA" (ByVal hDrop As Dword, ByVal uiFile As Dword, lpStr As Asciiz, ByVal cch As Dword) As Dword
Declare Function FreeLibrary Lib "KERNEL32.DLL" Alias "FreeLibrary" (ByVal hLibModule As Dword) As Long
Declare Function GetDC Lib "USER32.DLL" Alias "GetDC" (ByVal hWnd As Dword) As Dword
Declare Function GetDeviceCaps Lib "GDI32.DLL" Alias "GetDeviceCaps" (ByVal hdc As Dword, ByVal nIndex As Long) As Long
Declare Function GetFocus Lib "USER32.DLL" Alias "GetFocus" () As Dword
Declare Function GetProcAddress Lib "KERNEL32.DLL" Alias "GetProcAddress" (ByVal hModule As Dword, lpProcName As Asciiz) As Long
Declare Function LoadLibrary Lib "KERNEL32.DLL" Alias "LoadLibraryA" (lpLibFileName As Asciiz) As Long
Declare Function ReleaseDC Lib "USER32.DLL" Alias "ReleaseDC" (ByVal hWnd As Dword, ByVal hDC As Dword) As Long
Declare Function SetFocus Lib "USER32.DLL" Alias "SetFocus" (ByVal hWnd As Dword) As Long

'-----------------------------------------------------------------
' Declared Subs:  2
'-----------------------------------------------------------------

Declare Sub DragAcceptFiles Lib "SHELL32.DLL" Alias "DragAcceptFiles" (ByVal hwnd As Dword, ByVal fAccept As Long)
Declare Sub DragFinish Lib "SHELL32.DLL" Alias "DragFinish" (ByVal hDrop As Dword)

#If %Def(%UseFont)
#Include "pbforms.inc"
#EndIf

'**************************************

%PathLbl	= 1001
%PathTxt	= 1002
%MsgLbl		= 1003
%MsgTxt		= 1004
%FixBtn		= 1005
%CancelBtn	= 2
%HelpChk    = 1007

'**************************************

Global ghDlg	As Dword
Global gs		As String


'This is the default path:
$Path		= "C:\My Documents"
$MsgText	= "Drop the folder to process, or any file from it, to set the path."
$Title		= "CorelDraw File Fixer"

'**************************************

Function CorelDrawFix(ByVal ff As Long) As Long
Local n		As Long
Local p		As Long
Local ls	As String
Local rs	As String

	Get$ #ff, Lof(#ff), rs
	ls = Left$(rs, 22)
	p = InStr(rs, "INFOIKEY")
	p = InStr(-(Len(rs) - p), rs, "LIST")
	rs = Mid$(rs, p)

	n = Len(ls) + Len(rs)
	If n <> Lof(ff) Then
		Function = 1
		Mid$(ls, 5) = MkDwd$(n - 8) 'adjust length value
		Seek# ff, 1
		Put$ #ff, ls & rs
		SetEof# ff
	End If

End Function 'CorelDrawFix

'**************************************

Function CallFixer(ps As String) As String
Local bef   As Long
Local aft   As Long
Local tmp   As Long
Local n     As Long
Local ff    As Long
Local ls    As String

	ps = Trim$(ps) & "\"
	ls = Dir$(ps & "*.cdr")

	Do While Len(ls)

		FileCopy ps & ls, ps & ls & ".bak"

		ff = FreeFile
		Open ps & ls For Binary As #ff
		tmp = Lof(ff)

		If CorelDrawFix(ff) Then
			Incr n

			bef = bef + tmp
			SetEof# ff
			aft = aft + Lof(ff)

			If ghDlg Then
				Control Set Text ghDlg, %MsgTxt, "Done with file number: " & Str$(n) & $CrLf & ls
				Dialog DoEvents
			End If

		End If

		Close# ff
		ls = Dir$
	Loop

	ls = "Fixed " & Format$(n) & " files"

	'update log file
	ff = FreeFile
	Open "CorelDrawFix.log" For Append As #ff
	Print# ff, 
	Print# ff, "----------------------------------------"
	Print# ff, Time$ & ", " & Date$
	Print# ff, "Path: " & ps
	Print# ff, ls
	Close# ff

	Function = ls

End Function 'CallFixer

'**************************************

Sub ShowHelp()
Local ff	As Long
Local ls	As String

	Open "CorelDrawFix.txt" For Binary As #ff
	Get$ #ff, Lof(#ff), ls
	Close# ff
	Control Set Text ghDlg, %MsgTxt, ls

End Sub 'ShowHelp

'**************************************

CallBack Function DlgProc()
Local ff	As Long
Local n		As Long
Local ls	As String

	Select Case As Long CbMsg

		Case %WM_INITDIALOG
			Try
				ff = FreeFile
				Open "CorelDrawFix.ini" For Input As #ff
				Line Input# ff, ls
				Close# ff
			Catch
				ls = $Path
			End Try
			Control Set Text ghDlg, %PathTxt, ls

			DragAcceptFiles ghDlg, %TRUE

			Control Set Check ghDlg, %HelpChk, 1
			ShowHelp

		Case %WM_DROPFILES
			ls = String$(%MAX_PATH, $Nul)
			DragQueryFile CbWParam, 0, ByVal StrPtr(ls), %MAX_PATH
			ls = Left$(ls, InStr(-1, ls, "\") - 1)
			Control Set Text ghDlg, %PathTxt, ls
			DragFinish CbWParam

		Case %WM_DESTROY
			DragAcceptFiles ghDlg, %FALSE

			ff = FreeFile
			Open "CorelDrawFix.ini" For Output As #ff
			Control Get Text ghDlg, %PathTxt To ls
			Print# ff, ls
			Close# ff			

		Case %WM_NCACTIVATE
			Static hWndSaveFocus As Dword
			If Isfalse Cbwparam Then
				hWndSaveFocus = GetFocus()
			Elseif hWndSaveFocus Then
				SetFocus(hWndSaveFocus)
				hWndSaveFocus = 0
			End If

		Case %WM_HELP
			ShowHelp

		Case %WM_COMMAND
			Select Case As Long Cbctl

				Case %FixBtn
					If CbCtlMsg = %BN_CLICKED Or CbCtlMsg = 1 Then
						Control Set Text ghDlg, %MsgTxt, "Busy..."
						Control Get Text ghDlg, %PathTxt To ls
						Control Set Text ghDlg, %MsgTxt, CallFixer(ls)
					End If

				Case %CancelBtn
					If CbCtlMsg = %BN_CLICKED Or CbCtlMsg = 1 Then
						Dialog End ghDlg
					End If

				Case %HelpChk
					Control Get Check ghDlg, %HelpChk To n
					If n Then ShowHelp

			End Select

	End Select

End Function

'**************************************

Function PBMain()
Local lRslt As Long

	gs = Command$
	gs = Left$(gs, InStr(-1, gs, "\") - 1)
	If Len(gs) Then
		MsgBox CallFixer(gs), , $Title
		Exit Function
	End If

	Dialog New %HWND_DESKTOP, "CorelDraw File Fixer", 278, 62, 408, 256, %WS_POPUP Or %WS_BORDER Or _
		%WS_DLGFRAME Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MINIMIZEBOX Or %WS_CLIPSIBLINGS Or _
		%WS_VISIBLE Or %DS_MODALFRAME Or %DS_3DLOOK Or %DS_NOFAILCREATE Or %DS_SETFONT, _
		%WS_EX_ACCEPTFILES Or %WS_EX_CONTROLPARENT Or %WS_EX_LEFT Or %WS_EX_LTRREADING Or _
		%WS_EX_RIGHTSCROLLBAR, To ghDlg
	Control Add Label,   ghDlg, %PathLbl, "&Path:", 2, 1, 288, 10
	Control Add TextBox, ghDlg, %PathTxt, "", 2, 11, 288, 13

	Control Add Button,  ghDlg, %FixBtn, "&Fix it", 316, 8, 40, 16, %WS_CHILD Or %WS_VISIBLE Or _
		%WS_TABSTOP Or %BS_TEXT Or %BS_DEFPUSHBUTTON Or %BS_PUSHBUTTON Or %BS_CENTER Or _
		%BS_VCENTER, %WS_EX_LEFT Or %WS_EX_LTRREADING
	Dialog  Send		 ghDlg, %DM_SETDEFID, %FixBtn, 0
	Control Add Button,  ghDlg, %CancelBtn, "&Cancel", 364, 8, 40, 16
	Control Add CheckBox, ghDlg, %HelpChk, "Show &Help", 303, 35, 100, 10

	Control Add Label,	  ghDlg, %MsgLbl, "&Messages:", 2, 35, 288, 10
	Control Add TextBox, ghDlg, %MsgTxt, "", 2, 48, 403, 203, %WS_CHILD Or %WS_VISIBLE Or _
		%WS_TABSTOP Or %WS_VSCROLL Or %ES_LEFT Or %ES_MULTILINE Or %ES_AUTOHSCROLL Or _
		%ES_WANTRETURN, %WS_EX_CLIENTEDGE Or %WS_EX_LEFT Or %WS_EX_LTRREADING Or _
		%WS_EX_RIGHTSCROLLBAR

#If %Def(%UseFont)
	Local hFont1 As Dword
	hFont1 = PBFormsMakeFont("Courier New", 9, 400, %FALSE, %FALSE, %FALSE, %ANSI_CHARSET)
	Control Send ghDlg, %MsgTxt, %WM_SETFONT, hFont1, 0
#EndIf

	Dialog Show Modal ghDlg, Call DlgProc To lRslt

#If %Def(%UseFont)
	DeleteObject hFont1
#EndIf

	Function = lRslt

End Function

'**************************************

TheirCorp's SourceForge project
includes:
  • API Helper --- a code generator for the Win32 API
  • BinEditPlus --- a decompiler and more
  • ComHelper --- a code generator for the COM programming
  • "Flex" --- an editor with novel features
  • GDI Debug --- catches programming errors that could lead
    to resource leaks
  • Import Monitor --- (an API hook) Intercepts and monitors
    calls to imported functions
  • Intricately Mergeable Templates
  • Jellyfish Pro enhancer plugin (adds drag-and-drop and more..)
  • TheirEdit --- an editor for PowerBASIC code
  • TheirNote --- a KeyNote clone
  • TheirSheet --- a spreadsheet
  • SrcFrmt --- a source code formatter
  • Tooltipper --- a tooltip code generator


PowerBASIC article in Wikipedia
Attached Files