Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Saving with toolbar macro

I have done a lot of scripting with Word templates and have a save macro on
the toolbar to auto save to system. I have an ocx desktop control which will
pre-populate info on the new document.
I am trying to duplicate this effort in Excel but am having an issue when
saving.
With a new xlt template it will pre-load the data and when I use the toolbar
macro to save it works fine the first time.
Saves as "u:\COMM_red1.xls"
If I then delete the xls created and then new template it will pre-load fine
but, upon saving it errors. Says "red1.xls" could not be found.
I created the toolbar macro by:
1) Creating the macro code
2) Customize toolbar New 'SaveIR'
3) Commands Macro Custom button : dragged this to the toolbar macro
4) Right clicked on cutom button and assign macro 'SaveIR'

If I open the template and look at the assign macro it has
"U:\COMM_red1.xls" and not 'SaveIR'

What am doing wrong?

Here is my code of workbook open to load and the Save macro:

Workbook Open:
Private Sub Workbook_Open()
Sheets("Sheet1").Unprotect
Rows(92).Hidden = False
Rows(90).Hidden = False
Sheets("Sheet1").Protect
Set objIRConn = CreateObject("irdesktopcontrol.irdesktopcontrolx")
objIRConn.Active = True

If objIRConn.Active Then

Sheets("Sheet1").Unprotect

'Drawer
strdrawer = objIRConn.Drawer

'Insured Name
strInsName = objIRConn.Filename
Sheet1.Cells(7, 3) = strInsName

'Account Number
strAcctNum = objIRConn.FileNum
Sheet1.Cells(9, 3) = strAcctNum


If strdrawer = "COMM" Then
Sheet1.CheckBox1 = True
ElseIf strdrawer = "SCOM" Then
Sheet1.CheckBox2 = True
ElseIf strdrawer = "PSIC" Then
Sheet1.CheckBox3 = True
End If


objIRConn.Active = False
If IsNumeric(StrUD2) Then
Rows(92).Hidden = True
Else
Rows(90).Hidden = True
End If
Sheets("Sheet1").Protect
End If

End Sub

Save Macro:
Sub SaveIR()
On Error Resume Next
Set objIRConn = CreateObject("irdesktopcontrol.irdesktopcontrolx")
If VarType(objIRConn) 0 Then
objIRConn.Active = True


If objIRConn.Active Then
strdrawer = objIRConn.Drawer
strCL = objIRConn.Filename

Dim myTemp, myTempName
Set myTemp = ActiveDocument.AttachedTemplate
myTempName = myTemp.Name
Dim myTemp1, myTempName1
Set myTemp1 = ActiveDocument
myTempName1 = myTemp1.Name
pos2 = InStr(1, myTempName1, "DOC0")
pos3 = InStr(1, myTempName1, "DOT0")
pos6 = InStr(1, myTempName1, "~")
pos7 = InStr(1, myTempName1, ".")

msg = "Are you sure you want to Save Document to ImageRight?"
Style = vbYesNo + vbInformation + vbDefaultButton1
Response = MsgBox(msg, Style)

If Response = vbYes Then

'Page Description
pos1 = InStr(myTempName, ".")
strpg = Mid(myTempName, 1, (pos1 - 1))
strdesc = strpg


sFilename = "u:" + strdrawer + "_" + strCL + ".xls"
Application.DisplayAlerts = False

ActiveWorkbook.SaveAs Filename:=sFilename, _
FileFormat:=xlNormal, _
ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False

Application.Quit
Application.StatusBar = "Application Closing."

Else
ActiveWorkbook.Activate
End If

objIRConn.Active = False
End If
Set objIRConn = Nothing
End If
End Sub



Thanks,
Bryan


Reply
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
Toolbar saving problem Anthony Excel Discussion (Misc queries) 3 March 21st 05 06:17 PM
saving change in toolbar James Excel Worksheet Functions 1 February 10th 05 07:50 PM
saving toolbar choice Excel Discussion (Misc queries) 2 December 27th 04 08:22 PM
Saving VBA Toolbar Customisation RzB Excel Programming 2 October 31st 03 11:07 AM
saving toolbar buttons on custom toolbar Paul James Excel Programming 12 August 6th 03 08:28 AM


All times are GMT +1. The time now is 11:09 PM.

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

About Us

"It's about Microsoft Excel"