LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 116
Default How write Macro to save worksheet to a RELATIVE address

I have recorded a Macro to save a worksheet. Then I edited the macro to
change the ABSOLUTE file/address to a relative address (I want to save the
files in the same folder as the Excel program being run Nb It will run on
many different PCs), but the results seem 'unpreditable', sometimes when it
runs it writes them to the correct place and sometimes to 'MyDocument'?

Any ideas gratefully appreciated. My code is as follows:

Sub Macro2()
'
ActiveWorkbook.Save
MsgBox "Note: The current Spreadsheet has been automatically saved .. as
the name will now be changed by the program."
'
'
Sheets("meter_readings.xml").Select
ActiveWorkbook.SaveAs Filename:= _
"meter_readings.xml" _
, FileFormat:=xlUnicodeText, CreateBackup:=False

Sheets("meter_readings.html").Select
Range("A1:B10").Select
Range("B10").Activate
ActiveWorkbook.PublishObjects.Add(xlSourceRange, _
"meter_readings.html" _
, "meter_readings.html", "$A$1:$B$10", xlHtmlStatic,
"meter_readings_19233", "" _
).Publish (True)

'
MsgBox "Note: Both files have now been saved to the current
subdirectory. The Spreadsheet WILL now be closed without further saving ...
(as the name has been changed by the program)"
'
Workbooks("meter_readings.xml").Close SaveChanges:=False
End Sub


--
Thanks ... Barry
 
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
how do I write a request to 'Save As' Macro CRAIG K[_2_] Excel Discussion (Misc queries) 5 March 10th 08 01:31 PM
How do I avoid excel change absolute address to relative address Miguel Excel Discussion (Misc queries) 3 May 10th 07 11:18 PM
How to write macro that selects relative locations NewKid Excel Worksheet Functions 2 September 12th 06 07:41 PM
what is difference between absolute address and relative address? what is difference between absolute addr Excel Discussion (Misc queries) 1 July 22nd 06 08:17 AM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM


All times are GMT +1. The time now is 12:21 AM.

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"